Debian Codegraph @

packages/seacas/applications/nas2exo/N2ENasReader.h

raw
1 //============================================================================
2 // Name : testnas2exo.cpp
3 // Author : Ramon J. Moral (STRA LLC), John Niederhaus (Coordinator, SNL)
4 // Version :
5 // Copyright : (c) Sandia National Labs 2020, 2021, 2022, 2024
6 // Description : Testing nas2exo Library, C++ 14
7 //============================================================================
8
9 #pragma once
10
11 #include "N2EDataTypes.h"
12 #include <fstream>
13 #include <memory>
14 #include <string>
15 #include <vector>
16
17 using namespace N2EModules;
18
19 namespace NasModules {
20
21 class N2ENasReader
22 {
23
24 public:
25 N2ENasReader(std::string ifname = "");
26
27 inline unsigned getLineCount() { return this->lineCount; };
28 inline size_t getNumberGridPts() { return this->gridList.size(); };
29 inline size_t getNumberElems() { return this->elementList.size(); };
30 inline size_t getNumberSects() { return this->sections.size(); };
31 inline std::string getPath() { return this->inFileName; };
32
33 bool processFile();
34
35 std::vector<sectionType> getSections() { return this->sections; };
36 std::vector<gridType> getGridPoints() { return this->gridList; };
37 std::vector<elementType> getElementList() { return this->elementList; };
38
39 std::string getModelTitle();
40 void setModelTitle(const std::string &title = "");
41
42 protected:
43 std::string inFileName{};
44 std::unique_ptr<std::ifstream> inStream{};
45 unsigned lineCount{0u};
46
47 std::vector<sectionType> sections{};
48 std::vector<gridType> gridList{};
49 std::vector<elementType> elementList{};
50
51 std::string modelTitle{};
52
53 bool doesFileExist(const std::string &fname);
54 // Local buffer for reading faster
55 char _readBuffer[4096]{'\0'};
56
57 private:
58 unsigned lineCounter();
59 std::vector<std::string> csvLineToTokens(char buff[]);
60 };
61
62 } // namespace NasModules