OpenVolumeMesh
 All Classes Functions Variables Typedefs Pages
FileManager.hh
1 /*===========================================================================*\
2  * *
3  * OpenVolumeMesh *
4  * Copyright (C) 2011 by Computer Graphics Group, RWTH Aachen *
5  * www.openvolumemesh.org *
6  * *
7  *---------------------------------------------------------------------------*
8  * This file is part of OpenVolumeMesh. *
9  * *
10  * OpenVolumeMesh is free software: you can redistribute it and/or modify *
11  * it under the terms of the GNU Lesser General Public License as *
12  * published by the Free Software Foundation, either version 3 of *
13  * the License, or (at your option) any later version with the *
14  * following exceptions: *
15  * *
16  * If other files instantiate templates or use macros *
17  * or inline functions from this file, or you compile this file and *
18  * link it with other files to produce an executable, this file does *
19  * not by itself cause the resulting executable to be covered by the *
20  * GNU Lesser General Public License. This exception does not however *
21  * invalidate any other reasons why the executable file might be *
22  * covered by the GNU Lesser General Public License. *
23  * *
24  * OpenVolumeMesh is distributed in the hope that it will be useful, *
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
27  * GNU Lesser General Public License for more details. *
28  * *
29  * You should have received a copy of the GNU LesserGeneral Public *
30  * License along with OpenVolumeMesh. If not, *
31  * see <http://www.gnu.org/licenses/>. *
32  * *
33 \*===========================================================================*/
34 
35 /*===========================================================================*\
36  * *
37  * $Revision: 197 $ *
38  * $Date: 2012-05-11 13:44:53 +0200 (Fri, 11 May 2012) $ *
39  * $LastChangedBy: kremer $ *
40  * *
41 \*===========================================================================*/
42 
43 #ifndef FILEMANAGER_HH_
44 #define FILEMANAGER_HH_
45 
46 #include <string>
47 #include <fstream>
48 
49 namespace OpenVolumeMesh {
50 
51 namespace IO {
52 
60 class FileManager {
61 public:
62 
64  FileManager();
65 
67  ~FileManager();
68 
85  template <class MeshT>
86  bool readFile(const std::string& _filename, MeshT& _mesh,
87  bool _topologyCheck = true,
88  bool _computeBottomUpIncidences = true) const;
89 
100  template <class MeshT>
101  bool writeFile(const std::string& _filename, const MeshT& _mesh) const;
102 
106  bool isHexahedralMesh(const std::string& _filename) const;
107 
108 private:
109 
110  // Read property
111  template <class MeshT>
112  void readProperty(std::istream& _iff, MeshT& _mesh) const;
113 
114  template <class PropT, class MeshT>
115  void generateGenericProperty(const std::string& _entity_t, const std::string& _name,
116  std::istream& _iff, MeshT& _mesh) const;
117 
118  // Write props
119  template<class IteratorT>
120  void writeProps(std::ostream& _ostr, const IteratorT& _begin, const IteratorT& _end) const;
121 
122  // Remove leading and trailing whitespaces
123  void trimString(std::string& _string) const;
124 
125  // Get quoted text out of a string
126  void extractQuotedText(std::string& _string) const;
127 
128  // Get a whole line from file
129  bool getCleanLine(std::istream& ifs, std::string& _string, bool _skipEmptyLines = true) const;
130 };
131 
132 } // Namespace IO
133 
134 } // Namespace FileManager
135 
136 #if defined(INCLUDE_TEMPLATES) && !defined(FILEMANAGERT_CC)
137 #include "FileManagerT.cc"
138 #endif
139 
140 #endif /* FILEMANAGER_HH_ */