Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules 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$ *
38  * $Date$ *
39  * $LastChangedBy$ *
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 
111  bool isTetrahedralMesh(const std::string& _filename) const;
112 
113 
114 
115 private:
116 
117  // Read property
118  template <class MeshT>
119  void readProperty(std::istream& _iff, MeshT& _mesh) const;
120 
121  template <class PropT, class MeshT>
122  void generateGenericProperty(const std::string& _entity_t, const std::string& _name,
123  std::istream& _iff, MeshT& _mesh) const;
124 
125  // Write props
126  template<class IteratorT>
127  void writeProps(std::ostream& _ostr, const IteratorT& _begin, const IteratorT& _end) const;
128 
129  // Remove leading and trailing whitespaces
130  void trimString(std::string& _string) const;
131 
132  // Get quoted text out of a string
133  void extractQuotedText(std::string& _string) const;
134 
135  // Get a whole line from file
136  bool getCleanLine(std::istream& ifs, std::string& _string, bool _skipEmptyLines = true) const;
137 };
138 
139 } // Namespace IO
140 
141 } // Namespace FileManager
142 
143 #if defined(INCLUDE_TEMPLATES) && !defined(FILEMANAGERT_CC)
144 #include "FileManagerT.cc"
145 #endif
146 
147 #endif /* FILEMANAGER_HH_ */
bool readFile(const std::string &_filename, MeshT &_mesh, bool _topologyCheck=true, bool _computeBottomUpIncidences=true) const
Read a mesh from a file.
Definition: FileManagerT.cc:66
FileManager()
Default constructor.
Definition: FileManager.cc:62
Read/Write mesh data from/to files.
Definition: FileManager.hh:60
bool isTetrahedralMesh(const std::string &_filename) const
Test whether given file contains a tetrahedral mesh.
Definition: FileManager.cc:183
bool isHexahedralMesh(const std::string &_filename) const
Test whether given file contains a hexahedral mesh.
Definition: FileManager.cc:139
~FileManager()
Default destructor.
Definition: FileManager.cc:68
bool writeFile(const std::string &_filename, const MeshT &_mesh) const
Write a mesh to a file.