00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #ifndef OPENMESH_IO_OPTIONS_HH
00044 #define OPENMESH_IO_OPTIONS_HH
00045
00046
00047
00048
00049
00050
00051 #include <OpenMesh/Core/System/config.h>
00052
00053
00054
00055
00056
00057 namespace OpenMesh {
00058 namespace IO {
00059
00060
00061
00062
00063
00068
00069
00070
00071
00088 class Options
00089 {
00090 public:
00091 typedef int enum_type;
00092 typedef enum_type value_type;
00093
00096 enum Flag {
00097 Default = 0x0000,
00098 Binary = 0x0001,
00099 MSB = 0x0002,
00100 LSB = 0x0004,
00101 Swap = 0x0006,
00102 VertexNormal = 0x0010,
00103 VertexColor = 0x0020,
00104 VertexTexCoord = 0x0040,
00105 EdgeColor = 0x0080,
00106 FaceNormal = 0x0100,
00107 FaceColor = 0x0200,
00108 ColorAlpha = 0x0400
00109 };
00110
00111 public:
00112
00114 Options() : flags_( Default )
00115 { }
00116
00117
00119 Options(const Options& _opt) : flags_(_opt.flags_)
00120 { }
00121
00122
00124 Options(Flag _flg) : flags_( _flg)
00125 { }
00126
00127
00129 Options(const value_type _flgs) : flags_( _flgs)
00130 { }
00131
00132
00133 ~Options()
00134 { }
00135
00137 void cleanup(void)
00138 { flags_ = Default; }
00139
00141 void clear(void)
00142 { flags_ = 0; }
00143
00145 bool is_empty(void) const { return !flags_; }
00146
00147 public:
00148
00149
00151
00152
00153 Options& operator = ( const Options& _rhs )
00154 { flags_ = _rhs.flags_; return *this; }
00155
00156 Options& operator = ( const value_type _rhs )
00157 { flags_ = _rhs; return *this; }
00158
00160
00161
00163
00164
00165 Options& operator -= ( const value_type _rhs )
00166 { flags_ &= ~_rhs; return *this; }
00167
00168 Options& unset( const value_type _rhs)
00169 { return (*this -= _rhs); }
00170
00172
00173
00174
00176
00177
00178 Options& operator += ( const value_type _rhs )
00179 { flags_ |= _rhs; return *this; }
00180
00181 Options& set( const value_type _rhs)
00182 { return (*this += _rhs); }
00183
00185
00186 public:
00187
00188
00189
00190 bool check(const value_type _rhs) const
00191 {
00192 return (flags_ & _rhs)==_rhs;
00193 }
00194
00195 bool is_binary() const { return check(Binary); }
00196 bool vertex_has_normal() const { return check(VertexNormal); }
00197 bool vertex_has_color() const { return check(VertexColor); }
00198 bool vertex_has_texcoord() const { return check(VertexTexCoord); }
00199 bool edge_has_color() const { return check(EdgeColor); }
00200 bool face_has_normal() const { return check(FaceNormal); }
00201 bool face_has_color() const { return check(FaceColor); }
00202 bool color_has_alpha() const { return check(ColorAlpha); }
00203
00204
00206 bool operator == (const value_type _rhs) const
00207 { return flags_ == _rhs; }
00208
00209
00211 bool operator != (const value_type _rhs) const
00212 { return flags_ != _rhs; }
00213
00214
00216 operator value_type () const { return flags_; }
00217
00218 private:
00219
00220 bool operator && (const value_type _rhs) const;
00221
00222 value_type flags_;
00223 };
00224
00225
00226
00227
00228
00229
00231
00232
00233
00234 }
00235 }
00236
00237 #endif
00238