43 #define FILEMANAGERT_CC 51 #include <OpenVolumeMesh/Geometry/VectorT.hh> 52 #include <OpenVolumeMesh/Mesh/PolyhedralMesh.hh> 54 #include "FileManager.hh" 74 void FileManager::trimString(std::string& _string)
const {
77 size_t start = _string.find_first_not_of(
" \t\r\n");
78 size_t end = _string.find_last_not_of(
" \t\r\n");
80 if((std::string::npos == start) || (std::string::npos == end)) {
83 _string = _string.substr(start, end - start + 1);
89 void FileManager::extractQuotedText(std::string& _string)
const {
92 size_t start = _string.find_first_of(
"\""); ++start;
93 size_t end = _string.find_last_not_of(
"\"");
95 if((std::string::npos == start) || (std::string::npos == end)) {
98 _string = _string.substr(start, end - start + 1);
104 bool FileManager::getCleanLine(std::istream& _ifs, std::string& _string,
bool _skipEmptyLines)
const {
110 std::getline(_ifs, _string);
116 if(_string.size() != 0) {
119 if(_string[0] !=
'#') {
129 std::cerr <<
"End of file reached while searching for input!" << std::endl;
141 std::ifstream iff(_filename.c_str(), std::ios::in);
144 std::cerr <<
"Could not open file " << _filename <<
" for reading!" << std::endl;
153 while (
true || !iff.eof()) {
155 if (s ==
"Polyhedra") {
168 if(n == 0)
return false;
171 for (
unsigned int i = 0; i < n; ++i) {
173 iff.getline(tmp, 256);
185 std::ifstream iff(_filename.c_str(), std::ios::in);
188 std::cerr <<
"Could not open file " << _filename <<
" for reading!" << std::endl;
197 while (
true || !iff.eof()) {
199 if (s ==
"Polyhedra") {
212 if(n == 0)
return false;
215 for (
unsigned int i = 0; i < n; ++i) {
217 iff.getline(tmp, 256);
bool isTetrahedralMesh(const std::string &_filename) const
Test whether given file contains a tetrahedral mesh.
bool isHexahedralMesh(const std::string &_filename) const
Test whether given file contains a hexahedral mesh.
FileManager()
Default constructor.
~FileManager()
Default destructor.