OpenMesh
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Options.hh
1 /*===========================================================================*\
2  * *
3  * OpenMesh *
4  * Copyright (C) 2001-2015 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: 1188 $ *
38  * $Date: 2015-01-05 16:34:10 +0100 (Mo, 05 Jan 2015) $ *
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  Custom = 0x2000
112  };
113 
114 public:
115 
117  Options() : flags_( Default )
118  { }
119 
120 
122  Options(const Options& _opt) : flags_(_opt.flags_)
123  { }
124 
125 
127  Options(Flag _flg) : flags_( _flg)
128  { }
129 
130 
132  Options(const value_type _flgs) : flags_( _flgs)
133  { }
134 
135 
136  ~Options()
137  { }
138 
140  void cleanup(void)
141  { flags_ = Default; }
142 
144  void clear(void)
145  { flags_ = 0; }
146 
148  bool is_empty(void) const { return !flags_; }
149 
150 public:
151 
152 
154 
156  Options& operator = ( const Options& _rhs )
157  { flags_ = _rhs.flags_; return *this; }
158 
159  Options& operator = ( const value_type _rhs )
160  { flags_ = _rhs; return *this; }
161 
163 
164 
166 
168  Options& operator -= ( const value_type _rhs )
169  { flags_ &= ~_rhs; return *this; }
170 
171  Options& unset( const value_type _rhs)
172  { return (*this -= _rhs); }
173 
175 
176 
177 
179 
181  Options& operator += ( const value_type _rhs )
182  { flags_ |= _rhs; return *this; }
183 
184  Options& set( const value_type _rhs)
185  { return (*this += _rhs); }
186 
188 
189 public:
190 
191 
192  // Check if an option or several options are set.
193  bool check(const value_type _rhs) const
194  {
195  return (flags_ & _rhs)==_rhs;
196  }
197 
198  bool is_binary() const { return check(Binary); }
199  bool vertex_has_normal() const { return check(VertexNormal); }
200  bool vertex_has_color() const { return check(VertexColor); }
201  bool vertex_has_texcoord() const { return check(VertexTexCoord); }
202  bool edge_has_color() const { return check(EdgeColor); }
203  bool face_has_normal() const { return check(FaceNormal); }
204  bool face_has_color() const { return check(FaceColor); }
205  bool face_has_texcoord() const { return check(FaceTexCoord); }
206  bool color_has_alpha() const { return check(ColorAlpha); }
207  bool color_is_float() const { return check(ColorFloat); }
208 
209 
211  bool operator == (const value_type _rhs) const
212  { return flags_ == _rhs; }
213 
214 
216  bool operator != (const value_type _rhs) const
217  { return flags_ != _rhs; }
218 
219 
221  operator value_type () const { return flags_; }
222 
223 private:
224 
225  bool operator && (const value_type _rhs) const;
226 
227  value_type flags_;
228 };
229 
230 //-----------------------------------------------------------------------------
231 
232 
233 
234 
236 
237 
238 //=============================================================================
239 } // namespace IO
240 } // namespace OpenMesh
241 //=============================================================================
242 #endif
243 //=============================================================================
Flag
Definitions of Options for reading and writing.
Definition: Options.hh:96
Options & operator=(const Options &_rhs)
Copy options defined in _rhs.
Definition: Options.hh:156
Has (r) / store (w) face texture coordinates.
Definition: Options.hh:108
Options & set(const value_type _rhs)
Set options defined in _rhs.
Definition: Options.hh:184
void cleanup(void)
Restore state after default constructor.
Definition: Options.hh:140
Set binary mode for r/w.
Definition: Options.hh:98
Options & operator+=(const value_type _rhs)
Set options defined in _rhs.
Definition: Options.hh:181
Assume little endian byte ordering.
Definition: Options.hh:100
Options & unset(const value_type _rhs)
Unset options defined in _rhs.
Definition: Options.hh:171
Has (r) / store (w) alpha values for colors.
Definition: Options.hh:109
Has (r) / store (w) vertex colors.
Definition: Options.hh:103
Options(const Options &_opt)
Copy constructor.
Definition: Options.hh:122
Options(Flag _flg)
Initializing constructor setting a single option.
Definition: Options.hh:127
Has (r) / store (w) face colors.
Definition: Options.hh:107
Has (r) custom properties (currently only implemented in PLY Reader ASCII version) ...
Definition: Options.hh:111
Options & operator-=(const value_type _rhs)
Unset options defined in _rhs.
Definition: Options.hh:168
bool operator!=(const value_type _rhs) const
Returns true if _rhs does not have the same options enabled.
Definition: Options.hh:216
bool is_empty(void) const
Returns true if all bits are zero.
Definition: Options.hh:148
Has (r) / store (w) edge colors.
Definition: Options.hh:105
bool operator==(const value_type _rhs) const
Returns true if _rhs has the same options enabled.
Definition: Options.hh:211
Options(const value_type _flgs)
Initializing constructor setting multiple options.
Definition: Options.hh:132
Set options for reader/writer modules.
Definition: Options.hh:88
Has (r) / store (w) float values for colors (currently only implemented for PLY and OFF files) ...
Definition: Options.hh:110
Has (r) / store (w) texture coordinates.
Definition: Options.hh:104
No options.
Definition: Options.hh:97
Assume big endian byte ordering.
Definition: Options.hh:99
Has (r) / store (w) face normals.
Definition: Options.hh:106
Has (r) / store (w) vertex normals.
Definition: Options.hh:102
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:56
void clear(void)
Clear all bits.
Definition: Options.hh:144
Options()
Default constructor.
Definition: Options.hh:117
Swap byte order in binary mode.
Definition: Options.hh:101

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