Options.hh
/* ========================================================================= *
* *
* OpenMesh *
* Copyright (c) 2001-2015, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openmesh.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenMesh. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. Neither the name of the copyright holder nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
#ifndef OPENMESH_IO_OPTIONS_HH
#define OPENMESH_IO_OPTIONS_HH
//=== INCLUDES ================================================================
// OpenMesh
#include <OpenMesh/Core/System/config.h>
//== NAMESPACES ==============================================================
namespace OpenMesh {
namespace IO {
//=== IMPLEMENTATION ==========================================================
//-----------------------------------------------------------------------------
class Options
{
public:
typedef int enum_type;
typedef enum_type value_type;
enum Flag {
Default = 0x0000,
Binary = 0x0001,
MSB = 0x0002,
LSB = 0x0004,
Swap = 0x0008,
VertexNormal = 0x0010,
VertexColor = 0x0020,
VertexTexCoord = 0x0040,
EdgeColor = 0x0080,
FaceNormal = 0x0100,
FaceColor = 0x0200,
FaceTexCoord = 0x0400,
ColorAlpha = 0x0800,
ColorFloat = 0x1000,
Custom = 0x2000
};
public:
Options() : flags_( Default )
{ }
Options(const Options& _opt) : flags_(_opt.flags_)
{ }
Options(Flag _flg) : flags_( _flg)
{ }
Options(const value_type _flgs) : flags_( _flgs)
{ }
~Options()
{ }
void cleanup(void)
{ flags_ = Default; }
void clear(void)
{ flags_ = 0; }
bool is_empty(void) const { return !flags_; }
public:
Options& operator = ( const Options& _rhs )
{ flags_ = _rhs.flags_; return *this; }
Options& operator = ( const value_type _rhs )
{ flags_ = _rhs; return *this; }
Options& operator -= ( const value_type _rhs )
{ flags_ &= ~_rhs; return *this; }
Options& unset( const value_type _rhs)
{ return (*this -= _rhs); }
Options& operator += ( const value_type _rhs )
{ flags_ |= _rhs; return *this; }
Options& set( const value_type _rhs)
{ return (*this += _rhs); }
public:
// Check if an option or several options are set.
bool check(const value_type _rhs) const
{
return (flags_ & _rhs)==_rhs;
}
bool is_binary() const { return check(Binary); }
bool vertex_has_normal() const { return check(VertexNormal); }
bool vertex_has_color() const { return check(VertexColor); }
bool vertex_has_texcoord() const { return check(VertexTexCoord); }
bool edge_has_color() const { return check(EdgeColor); }
bool face_has_normal() const { return check(FaceNormal); }
bool face_has_color() const { return check(FaceColor); }
bool face_has_texcoord() const { return check(FaceTexCoord); }
bool color_has_alpha() const { return check(ColorAlpha); }
bool color_is_float() const { return check(ColorFloat); }
bool operator == (const value_type _rhs) const
{ return flags_ == _rhs; }
bool operator != (const value_type _rhs) const
{ return flags_ != _rhs; }
operator value_type () const { return flags_; }
private:
bool operator && (const value_type _rhs) const;
value_type flags_;
};
//-----------------------------------------------------------------------------
//=============================================================================
} // namespace IO
} // namespace OpenMesh
//=============================================================================
#endif
//=============================================================================
OpenMesh::IO::Options::ColorAlpha
Has (r) / store (w) alpha values for colors.
Definition: Options.hh:116
OpenMesh::IO::Options::clear
void clear(void)
Clear all bits.
Definition: Options.hh:151
OpenMesh::IO::Options::Default
No options.
Definition: Options.hh:104
OpenMesh::IO::Options::VertexTexCoord
Has (r) / store (w) texture coordinates.
Definition: Options.hh:111
OpenMesh::IO::Options::operator-=
Options & operator-=(const value_type _rhs)
Unset options defined in _rhs.
Definition: Options.hh:175
OpenMesh::IO::Options::operator+=
Options & operator+=(const value_type _rhs)
Set options defined in _rhs.
Definition: Options.hh:188
OpenMesh::IO::Options::MSB
Assume big endian byte ordering.
Definition: Options.hh:106
OpenMesh::IO::Options::Options
Options(const value_type _flgs)
Initializing constructor setting multiple options.
Definition: Options.hh:139
OpenMesh::IO::Options::is_empty
bool is_empty(void) const
Returns true if all bits are zero.
Definition: Options.hh:155
OpenMesh::IO::Options::cleanup
void cleanup(void)
Restore state after default constructor.
Definition: Options.hh:147
OpenMesh::IO::Options::EdgeColor
Has (r) / store (w) edge colors.
Definition: Options.hh:112
OpenMesh::IO::Options::FaceTexCoord
Has (r) / store (w) face texture coordinates.
Definition: Options.hh:115
OpenMesh
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:64
OpenMesh::IO::Options::Binary
Set binary mode for r/w.
Definition: Options.hh:105
OpenMesh::IO::Options::unset
Options & unset(const value_type _rhs)
Unset options defined in _rhs.
Definition: Options.hh:178
OpenMesh::IO::Options::operator=
Options & operator=(const Options &_rhs)
Copy options defined in _rhs.
Definition: Options.hh:163
OpenMesh::IO::Options::Options
Options(Flag _flg)
Initializing constructor setting a single option.
Definition: Options.hh:134
OpenMesh::IO::Options::LSB
Assume little endian byte ordering.
Definition: Options.hh:107
OpenMesh::IO::Options::Flag
Flag
Definitions of Options for reading and writing.
Definition: Options.hh:103
OpenMesh::IO::Options::FaceNormal
Has (r) / store (w) face normals.
Definition: Options.hh:113
OpenMesh::IO::Options::FaceColor
Has (r) / store (w) face colors.
Definition: Options.hh:114
OpenMesh::IO::Options::VertexNormal
Has (r) / store (w) vertex normals.
Definition: Options.hh:109
OpenMesh::IO::Options::VertexColor
Has (r) / store (w) vertex colors.
Definition: Options.hh:110
OpenMesh::IO::Options::Options
Options(const Options &_opt)
Copy constructor.
Definition: Options.hh:129
OpenMesh::IO::Options::Swap
Swap byte order in binary mode.
Definition: Options.hh:108
OpenMesh::IO::Options
Set options for reader/writer modules.
Definition: Options.hh:95
Custom
Definition: unittests_common_customtraits.hh:7
OpenMesh::IO::Options::operator==
bool operator==(const value_type _rhs) const
Returns true if _rhs has the same options enabled.
Definition: Options.hh:218
OpenMesh::IO::Options::operator!=
bool operator!=(const value_type _rhs) const
Returns true if _rhs does not have the same options enabled.
Definition: Options.hh:223
OpenMesh::IO::Options::ColorFloat
Has (r) / store (w) float values for colors (currently only implemented for PLY and OFF files) ...
Definition: Options.hh:117
OpenMesh::IO::Options::Options
Options()
Default constructor.
Definition: Options.hh:124