OpenMesh

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MeshIO.hh
1 /*===========================================================================*\
2 * *
3 * OpenMesh *
4 * Copyright (C) 2001-2012 by Computer Graphics Group, RWTH Aachen *
5 * www.openmesh.org *
6 * *
7 *---------------------------------------------------------------------------*
8 * This file is part of OpenMesh. *
9 * *
10 * OpenMesh 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 * OpenMesh 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 OpenMesh. If not, *
31 * see <http://www.gnu.org/licenses/>. *
32 * *
33 \*===========================================================================*/
34
35 /*===========================================================================*\
36 * *
37 * $Revision: 809 $ *
38 * $Date: 2013-02-25 14:30:56 +0100 (Mo, 25. Feb 2013) $ *
39 * *
40 \*===========================================================================*/
41
42
43 #ifndef OM_MESHIO_HH
44 #define OM_MESHIO_HH
45
46
47 //=== INCLUDES ================================================================
48
49 // -------------------- system settings
50 #include <OpenMesh/Core/System/config.h>
51 // -------------------- check include order
52 #if defined (OPENMESH_TRIMESH_ARRAY_KERNEL_HH) || \
53 defined (OPENMESH_POLYMESH_ARRAY_KERNEL_HH)
54 # error "Include MeshIO.hh before including a mesh type!"
55 #endif
56 // -------------------- OpenMesh
57 #include <OpenMesh/Core/IO/SR_store.hh>
58 #include <OpenMesh/Core/IO/IOManager.hh>
59 #include <OpenMesh/Core/IO/importer/ImporterT.hh>
60 #include <OpenMesh/Core/IO/exporter/ExporterT.hh>
61
62
63 //== NAMESPACES ==============================================================
64
65 namespace OpenMesh {
66 namespace IO {
67
68
69 //=== IMPLEMENTATION ==========================================================
70
71
77
78
79 //-----------------------------------------------------------------------------
80
81
95 template <class Mesh>
96 bool
97 read_mesh(Mesh& _mesh,
98 const std::string& _filename)
99 {
100 Options opt;
101 return read_mesh(_mesh, _filename, opt, true);
102 }
103
104
125 template <class Mesh>
126 bool
127 read_mesh(Mesh& _mesh,
128 const std::string& _filename,
129 Options& _opt,
130 bool _clear = true)
131 {
132 if (_clear) _mesh.clear();
133 ImporterT<Mesh> importer(_mesh);
134 return IOManager().read(_filename, importer, _opt);
135 }
136
137
157 template <class Mesh>
158 bool
159 read_mesh(Mesh& _mesh,
160 std::istream& _is,
161 const std::string& _ext,
162 Options& _opt,
163 bool _clear = true)
164 {
165 if (_clear) _mesh.clear();
166 ImporterT<Mesh> importer(_mesh);
167 return IOManager().read(_is,_ext, importer, _opt);
168 }
169
170
171
172 //-----------------------------------------------------------------------------
173
174
191 template <class Mesh>
192 bool write_mesh(const Mesh& _mesh,
193 const std::string& _filename,
194 Options _opt = Options::Default,
195 std::streamsize _precision = 6)
196 {
197 ExporterT<Mesh> exporter(_mesh);
198 return IOManager().write(_filename, exporter, _opt, _precision);
199 }
200
201
202 //-----------------------------------------------------------------------------
203
204
223 template <class Mesh>
224 bool write_mesh(const Mesh& _mesh,
225 std::ostream& _os,
226 const std::string& _ext,
227 Options _opt = Options::Default,
228 std::streamsize _precision = 6)
229 {
230 ExporterT<Mesh> exporter(_mesh);
231 return IOManager().write(_os,_ext, exporter, _opt, _precision);
232 }
233
234
235 //-----------------------------------------------------------------------------
236
252 template <class Mesh>
253 size_t binary_size(const Mesh& _mesh,
254 const std::string& _ext,
255 Options _opt = Options::Default)
256 {
257 ExporterT<Mesh> exporter(_mesh);
258 return IOManager().binary_size(_ext, exporter, _opt);
259 }
260
261
262 //-----------------------------------------------------------------------------
263
265
266
267 //=============================================================================
268 } // namespace IO
269 } // namespace OpenMesh
270 //=============================================================================
271 #if defined(OM_STATIC_BUILD) || defined(ARCH_DARWIN)
272 # include <OpenMesh/Core/IO/IOInstances.hh>
273 #endif
274 //=============================================================================
275 #endif
276 //=============================================================================