Developer Documentation
Loading...
Searching...
No Matches
FileManager.hh
1#pragma once
2/*===========================================================================*\
3 * *
4 * OpenVolumeMesh *
5 * Copyright (C) 2011 by Computer Graphics Group, RWTH Aachen *
6 * www.openvolumemesh.org *
7 * *
8 *---------------------------------------------------------------------------*
9 * This file is part of OpenVolumeMesh. *
10 * *
11 * OpenVolumeMesh is free software: you can redistribute it and/or modify *
12 * it under the terms of the GNU Lesser General Public License as *
13 * published by the Free Software Foundation, either version 3 of *
14 * the License, or (at your option) any later version with the *
15 * following exceptions: *
16 * *
17 * If other files instantiate templates or use macros *
18 * or inline functions from this file, or you compile this file and *
19 * link it with other files to produce an executable, this file does *
20 * not by itself cause the resulting executable to be covered by the *
21 * GNU Lesser General Public License. This exception does not however *
22 * invalidate any other reasons why the executable file might be *
23 * covered by the GNU Lesser General Public License. *
24 * *
25 * OpenVolumeMesh is distributed in the hope that it will be useful, *
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
28 * GNU Lesser General Public License for more details. *
29 * *
30 * You should have received a copy of the GNU LesserGeneral Public *
31 * License along with OpenVolumeMesh. If not, *
32 * see <http://www.gnu.org/licenses/>. *
33 * *
34\*===========================================================================*/
35
36
37#include <string>
38#include <fstream>
39#include <istream>
40#include <ostream>
41#include <OpenVolumeMesh/Config/Export.hh>
42
43namespace OpenVolumeMesh {
44
45namespace IO {
46
54class OVM_EXPORT FileManager {
55public:
56
59
62
63
68 void setVerbosityLevel(int _level) { verbosity_level_ = _level;}
69
86 template <class MeshT>
87 bool readStream(std::istream &_istream, MeshT& _mesh,
88 bool _topologyCheck = true,
89 bool _computeBottomUpIncidences = true) const;
90
107 template <class MeshT>
108 bool readFile(const std::string& _filename, MeshT& _mesh,
109 bool _topologyCheck = true,
110 bool _computeBottomUpIncidences = true) const;
111
112
119 template <class MeshT>
120 void writeStream(std::ostream &_ostream, const MeshT& _mesh) const;
121
122
133 template <class MeshT>
134 bool writeFile(const std::string& _filename, const MeshT& _mesh) const;
135
139 bool isHexahedralMesh(const std::string& _filename) const;
140
144 bool isTetrahedralMesh(const std::string& _filename) const;
145
146
147
148private:
149
150
151 // Read property
152 template <class MeshT>
153 void readProperty(std::istream& _iff, MeshT& _mesh) const;
154
155 template <class PropT, class MeshT>
156 void generateGenericProperty(const std::string& _entity_t, const std::string& _name,
157 std::istream& _iff, MeshT& _mesh) const;
158
159 template<typename EntityTag, class MeshT>
160 void writeProps(std::ostream &_ostream, const MeshT& _mesh) const;
161 // Write props
162 template<class IteratorT>
163 void writeProps(std::ostream& _ostr, const IteratorT& _begin, const IteratorT& _end, std::string const &_entityType) const;
164
165 // Remove leading and trailing whitespaces
166 void trimString(std::string& _string) const;
167
168 // Get quoted text out of a string
169 void extractQuotedText(std::string& _string) const;
170
171 // Get a whole line from file
172 bool getCleanLine(std::istream& ifs, std::string& _string, bool _skipEmptyLines = true) const;
173
174
175 int verbosity_level_ = 3;
176};
177
178} // Namespace IO
179
180} // Namespace FileManager
181
182#include <OpenVolumeMesh/FileManager/FileManagerT_impl.hh>
Read/Write mesh data from/to files.
void setVerbosityLevel(int _level)
set minimum level for errors that are printed to std::cerr