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
OMReader.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: 743 $ *
38 * $Date: 2012-10-08 15:25:36 +0200 (Mo, 08. Okt 2012) $ *
39 * *
40 \*===========================================================================*/
41
42
43 //=============================================================================
44 //
45 // Implements a reader module for OFF files
46 //
47 //=============================================================================
48
49
50 #ifndef __OMREADER_HH__
51 #define __OMREADER_HH__
52
53
54 //=== INCLUDES ================================================================
55
56 // OpenMesh
57 #include <OpenMesh/Core/System/config.h>
58 #include <OpenMesh/Core/Utils/SingletonT.hh>
59 #include <OpenMesh/Core/IO/OMFormat.hh>
60 #include <OpenMesh/Core/IO/IOManager.hh>
61 #include <OpenMesh/Core/IO/importer/BaseImporter.hh>
62 #include <OpenMesh/Core/IO/reader/BaseReader.hh>
63
64 // STD C++
65 #include <iostream>
66 #include <string>
67
68
69 //== NAMESPACES ===============================================================
70
71
72 namespace OpenMesh {
73 namespace IO {
74
75
76 //== IMPLEMENTATION ===========================================================
77
78
83 class OPENMESHDLLEXPORT _OMReader_ : public BaseReader
84 {
85 public:
86
87 _OMReader_();
88 virtual ~_OMReader_() { }
89
90 std::string get_description() const { return "OpenMesh File Format"; }
91 std::string get_extensions() const { return "om"; }
92 std::string get_magic() const { return "OM"; }
93
94 bool read(const std::string& _filename,
95 BaseImporter& _bi,
96 Options& _opt );
97
99 bool read(std::istream& _is,
100 BaseImporter& _bi,
101 Options& _opt );
102
103 virtual bool can_u_read(const std::string& _filename) const;
104 virtual bool can_u_read(std::istream& _is) const;
105
106
107 private:
108
109 bool supports( const OMFormat::uint8 version ) const;
110
111 bool read_ascii(std::istream& _is, BaseImporter& _bi, Options& _opt) const;
112 bool read_binary(std::istream& _is, BaseImporter& _bi, Options& _opt) const;
113
114 typedef OMFormat::Header Header;
115 typedef OMFormat::Chunk::Header ChunkHeader;
116 typedef OMFormat::Chunk::PropertyName PropertyName;
117
118 // initialized/updated by read_binary*/read_ascii*
119 mutable size_t bytes_;
120 mutable Options fileOptions_;
121 mutable Header header_;
122 mutable ChunkHeader chunk_header_;
123 mutable PropertyName property_name_;
124
125 bool read_binary_vertex_chunk( std::istream &_is,
126 BaseImporter &_bi,
127 Options &_opt,
128 bool _swap) const;
129
130 bool read_binary_face_chunk( std::istream &_is,
131 BaseImporter &_bi,
132 Options &_opt,
133 bool _swap) const;
134
135 bool read_binary_edge_chunk( std::istream &_is,
136 BaseImporter &_bi,
137 Options &_opt,
138 bool _swap) const;
139
140 bool read_binary_halfedge_chunk( std::istream &_is,
141 BaseImporter &_bi,
142 Options &_opt,
143 bool _swap) const;
144
145 bool read_binary_mesh_chunk( std::istream &_is,
146 BaseImporter &_bi,
147 Options &_opt,
148 bool _swap) const;
149
150 size_t restore_binary_custom_data( std::istream& _is,
151 BaseProperty* _bp,
152 size_t _n_elem,
153 bool _swap) const;
154
155 };
156
157
158 //== TYPE DEFINITION ==========================================================
159
160
162 extern _OMReader_ __OMReaderInstance;
163 OPENMESHDLLEXPORT _OMReader_& OMReader();
164
165
166 //=============================================================================
167 } // namespace IO
168 } // namespace OpenMesh
169 //=============================================================================
170 #endif
171 //=============================================================================