OpenMesh
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Options.hh
1 /*===========================================================================*\
2  * *
3  * OpenMesh *
4  * Copyright (C) 2001-2011 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: 362 $ *
38  * $Date: 2011-01-26 10:21:12 +0100 (Mi, 26 Jan 2011) $ *
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  ColorAlpha = 0x0400
109  };
110 
111 public:
112 
114  Options() : flags_( Default )
115  { }
116 
117 
119  Options(const Options& _opt) : flags_(_opt.flags_)
120  { }
121 
122 
124  Options(Flag _flg) : flags_( _flg)
125  { }
126 
127 
129  Options(const value_type _flgs) : flags_( _flgs)
130  { }
131 
132 
133  ~Options()
134  { }
135 
137  void cleanup(void)
138  { flags_ = Default; }
139 
141  void clear(void)
142  { flags_ = 0; }
143 
145  bool is_empty(void) const { return !flags_; }
146 
147 public:
148 
149 
151 
152 
153  Options& operator = ( const Options& _rhs )
154  { flags_ = _rhs.flags_; return *this; }
155 
156  Options& operator = ( const value_type _rhs )
157  { flags_ = _rhs; return *this; }
158 
160 
161 
163 
164 
165  Options& operator -= ( const value_type _rhs )
166  { flags_ &= ~_rhs; return *this; }
167 
168  Options& unset( const value_type _rhs)
169  { return (*this -= _rhs); }
170 
172 
173 
174 
176 
177 
178  Options& operator += ( const value_type _rhs )
179  { flags_ |= _rhs; return *this; }
180 
181  Options& set( const value_type _rhs)
182  { return (*this += _rhs); }
183 
185 
186 public:
187 
188 
189  // Check if an option or several options are set.
190  bool check(const value_type _rhs) const
191  {
192  return (flags_ & _rhs)==_rhs;
193  }
194 
195  bool is_binary() const { return check(Binary); }
196  bool vertex_has_normal() const { return check(VertexNormal); }
197  bool vertex_has_color() const { return check(VertexColor); }
198  bool vertex_has_texcoord() const { return check(VertexTexCoord); }
199  bool edge_has_color() const { return check(EdgeColor); }
200  bool face_has_normal() const { return check(FaceNormal); }
201  bool face_has_color() const { return check(FaceColor); }
202  bool color_has_alpha() const { return check(ColorAlpha); }
203 
204 
206  bool operator == (const value_type _rhs) const
207  { return flags_ == _rhs; }
208 
209 
211  bool operator != (const value_type _rhs) const
212  { return flags_ != _rhs; }
213 
214 
216  operator value_type () const { return flags_; }
217 
218 private:
219 
220  bool operator && (const value_type _rhs) const;
221 
222  value_type flags_;
223 };
224 
225 //-----------------------------------------------------------------------------
226 
227 
228 
229 
231 
232 
233 //=============================================================================
234 } // namespace IO
235 } // namespace OpenMesh
236 //=============================================================================
237 #endif
238 //=============================================================================

acg pic Project OpenMesh, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .