OpenMesh
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends 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: 819 $ *
38  * $Date: 2013-03-04 18:09:45 +0100 (Mo, 04. Mär 2013) $ *
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  ColorFloat = 0x1000
111  };
112 
113 public:
114 
116  Options() : flags_( Default )
117  { }
118 
119 
121  Options(const Options& _opt) : flags_(_opt.flags_)
122  { }
123 
124 
126  Options(Flag _flg) : flags_( _flg)
127  { }
128 
129 
131  Options(const value_type _flgs) : flags_( _flgs)
132  { }
133 
134 
135  ~Options()
136  { }
137 
139  void cleanup(void)
140  { flags_ = Default; }
141 
143  void clear(void)
144  { flags_ = 0; }
145 
147  bool is_empty(void) const { return !flags_; }
148 
149 public:
150 
151 
153 
154 
155  Options& operator = ( const Options& _rhs )
156  { flags_ = _rhs.flags_; return *this; }
157 
158  Options& operator = ( const value_type _rhs )
159  { flags_ = _rhs; return *this; }
160 
162 
163 
165 
166 
167  Options& operator -= ( const value_type _rhs )
168  { flags_ &= ~_rhs; return *this; }
169 
170  Options& unset( const value_type _rhs)
171  { return (*this -= _rhs); }
172 
174 
175 
176 
178 
179 
180  Options& operator += ( const value_type _rhs )
181  { flags_ |= _rhs; return *this; }
182 
183  Options& set( const value_type _rhs)
184  { return (*this += _rhs); }
185 
187 
188 public:
189 
190 
191  // Check if an option or several options are set.
192  bool check(const value_type _rhs) const
193  {
194  return (flags_ & _rhs)==_rhs;
195  }
196 
197  bool is_binary() const { return check(Binary); }
198  bool vertex_has_normal() const { return check(VertexNormal); }
199  bool vertex_has_color() const { return check(VertexColor); }
200  bool vertex_has_texcoord() const { return check(VertexTexCoord); }
201  bool edge_has_color() const { return check(EdgeColor); }
202  bool face_has_normal() const { return check(FaceNormal); }
203  bool face_has_color() const { return check(FaceColor); }
204  bool face_has_texcoord() const { return check(FaceTexCoord); }
205  bool color_has_alpha() const { return check(ColorAlpha); }
206  bool color_is_float() const { return check(ColorFloat); }
207 
208 
210  bool operator == (const value_type _rhs) const
211  { return flags_ == _rhs; }
212 
213 
215  bool operator != (const value_type _rhs) const
216  { return flags_ != _rhs; }
217 
218 
220  operator value_type () const { return flags_; }
221 
222 private:
223 
224  bool operator && (const value_type _rhs) const;
225 
226  value_type flags_;
227 };
228 
229 //-----------------------------------------------------------------------------
230 
231 
232 
233 
235 
236 
237 //=============================================================================
238 } // namespace IO
239 } // namespace OpenMesh
240 //=============================================================================
241 #endif
242 //=============================================================================

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