OpenMesh

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

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Options.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: 738 $ *
38 * $Date: 2012-10-08 11:45:20 +0200 (Mo, 08 Okt 2012) $ *
39 * *
40 \*===========================================================================*/
41
42
43 #ifndef OPENMESH_IO_OPTIONS_HH
44 #define OPENMESH_IO_OPTIONS_HH
45
46
47 //=== INCLUDES ================================================================
48
49
50 // OpenMesh
51 #include <OpenMesh/Core/System/config.h>
52
53
54 //== NAMESPACES ==============================================================
55
56
57 namespace OpenMesh {
58 namespace IO {
59
60
61 //=== IMPLEMENTATION ==========================================================
62
63
68
69
70 //-----------------------------------------------------------------------------
71
88 class Options
89 {
90 public:
91 typedef int enum_type;
92 typedef enum_type value_type;
93
96 enum Flag {
97 Default = 0x0000,
98 Binary = 0x0001,
99 MSB = 0x0002,
100 LSB = 0x0004,
101 Swap = 0x0006,
102 VertexNormal = 0x0010,
103 VertexColor = 0x0020,
104 VertexTexCoord = 0x0040,
105 EdgeColor = 0x0080,
106 FaceNormal = 0x0100,
107 FaceColor = 0x0200,
108 FaceTexCoord = 0x0400,
109 ColorAlpha = 0x0800
110 };
111
112 public:
113
115 Options() : flags_( Default )
116 { }
117
118
120 Options(const Options& _opt) : flags_(_opt.flags_)
121 { }
122
123
125 Options(Flag _flg) : flags_( _flg)
126 { }
127
128
130 Options(const value_type _flgs) : flags_( _flgs)
131 { }
132
133
134 ~Options()
135 { }
136
138 void cleanup(void)
139 { flags_ = Default; }
140
142 void clear(void)
143 { flags_ = 0; }
144
146 bool is_empty(void) const { return !flags_; }
147
148 public:
149
150
152
153
154 Options& operator = ( const Options& _rhs )
155 { flags_ = _rhs.flags_; return *this; }
156
157 Options& operator = ( const value_type _rhs )
158 { flags_ = _rhs; return *this; }
159
161
162
164
165
166 Options& operator -= ( const value_type _rhs )
167 { flags_ &= ~_rhs; return *this; }
168
169 Options& unset( const value_type _rhs)
170 { return (*this -= _rhs); }
171
173
174
175
177
178
179 Options& operator += ( const value_type _rhs )
180 { flags_ |= _rhs; return *this; }
181
182 Options& set( const value_type _rhs)
183 { return (*this += _rhs); }
184
186
187 public:
188
189
190 // Check if an option or several options are set.
191 bool check(const value_type _rhs) const
192 {
193 return (flags_ & _rhs)==_rhs;
194 }
195
196 bool is_binary() const { return check(Binary); }
197 bool vertex_has_normal() const { return check(VertexNormal); }
198 bool vertex_has_color() const { return check(VertexColor); }
199 bool vertex_has_texcoord() const { return check(VertexTexCoord); }
200 bool edge_has_color() const { return check(EdgeColor); }
201 bool face_has_normal() const { return check(FaceNormal); }
202 bool face_has_color() const { return check(FaceColor); }
203 bool face_has_texcoord() const { return check(FaceTexCoord); }
204 bool color_has_alpha() const { return check(ColorAlpha); }
205
206
208 bool operator == (const value_type _rhs) const
209 { return flags_ == _rhs; }
210
211
213 bool operator != (const value_type _rhs) const
214 { return flags_ != _rhs; }
215
216
218 operator value_type () const { return flags_; }
219
220 private:
221
222 bool operator && (const value_type _rhs) const;
223
224 value_type flags_;
225 };
226
227 //-----------------------------------------------------------------------------
228
229
230
231
233
234
235 //=============================================================================
236 } // namespace IO
237 } // namespace OpenMesh
238 //=============================================================================
239 #endif
240 //=============================================================================