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 FaceNormal = 0x0100,
00106 FaceColor = 0x0200,
00107 ColorAlpha = 0x0400
00108 };
00109
00110 public:
00111
00113 Options() : flags_( Default )
00114 { }
00115
00116
00118 Options(const Options& _opt) : flags_(_opt.flags_)
00119 { }
00120
00121
00123 Options(Flag _flg) : flags_( _flg)
00124 { }
00125
00126
00128 Options(const value_type _flgs) : flags_( _flgs)
00129 { }
00130
00131
00132 ~Options()
00133 { }
00134
00136 void cleanup(void)
00137 { flags_ = Default; }
00138
00140 void clear(void)
00141 { flags_ = 0; }
00142
00144 bool is_empty(void) const { return !flags_; }
00145
00146 public:
00147
00148
00150
00151
00152 Options& operator = ( const Options& _rhs )
00153 { flags_ = _rhs.flags_; return *this; }
00154
00155 Options& operator = ( const value_type _rhs )
00156 { flags_ = _rhs; return *this; }
00157
00159
00160
00162
00163
00164 Options& operator -= ( const value_type _rhs )
00165 { flags_ &= ~_rhs; return *this; }
00166
00167 Options& unset( const value_type _rhs)
00168 { return (*this -= _rhs); }
00169
00171
00172
00173
00175
00176
00177 Options& operator += ( const value_type _rhs )
00178 { flags_ |= _rhs; return *this; }
00179
00180 Options& set( const value_type _rhs)
00181 { return (*this += _rhs); }
00182
00184
00185 public:
00186
00187
00188
00189 bool check(const value_type _rhs) const
00190 {
00191 return (flags_ & _rhs)==_rhs;
00192 }
00193
00194 bool is_binary() const { return check(Binary); }
00195 bool vertex_has_normal() const { return check(VertexNormal); }
00196 bool vertex_has_color() const { return check(VertexColor); }
00197 bool vertex_has_texcoord() const { return check(VertexTexCoord); }
00198 bool face_has_normal() const { return check(FaceNormal); }
00199 bool face_has_color() const { return check(FaceColor); }
00200 bool color_has_alpha() const { return check(ColorAlpha); }
00201
00202
00204 bool operator == (const value_type _rhs) const
00205 { return flags_ == _rhs; }
00206
00207
00209 bool operator != (const value_type _rhs) const
00210 { return flags_ != _rhs; }
00211
00212
00214 operator value_type () const { return flags_; }
00215
00216 private:
00217
00218 bool operator && (const value_type _rhs) const;
00219
00220 value_type flags_;
00221 };
00222
00223
00224
00225
00226
00227
00229
00230
00231
00232 }
00233 }
00234
00235 #endif
00236