Loading...
Searching...
No Matches
Options.hh
/* ========================================================================= *
* *
* OpenMesh *
* Copyright (c) 2001-2022, 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. *
* *
* ========================================================================= */
#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,
Status = 0x4000,
TexCoordST = 0x8000
};
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 vertex_has_status() const { return check(Status); }
bool edge_has_color() const { return check(EdgeColor); }
bool edge_has_status() const { return check(Status); }
bool halfedge_has_status() const { return check(Status); }
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 face_has_status() const { return check(Status); }
bool color_has_alpha() const { return check(ColorAlpha); }
bool color_is_float() const { return check(ColorFloat); }
bool use_st_coordinates() const { return check(TexCoordST); }
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
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition MeshItems.hh:59
OpenMesh::IO::Options
Set options for reader/writer modules.
Definition Options.hh:91
OpenMesh::IO::Options::operator+=
Options & operator+=(const value_type _rhs)
Set options defined in _rhs.
Definition Options.hh:185
OpenMesh::IO::Options::Options
Options(const value_type _flgs)
Initializing constructor setting multiple options.
Definition Options.hh:136
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:225
OpenMesh::IO::Options::cleanup
void cleanup(void)
Restore state after default constructor.
Definition Options.hh:144
OpenMesh::IO::Options::is_empty
bool is_empty(void) const
Returns true if all bits are zero.
Definition Options.hh:152
OpenMesh::IO::Options::operator==
bool operator==(const value_type _rhs) const
Returns true if _rhs has the same options enabled.
Definition Options.hh:220
OpenMesh::IO::Options::clear
void clear(void)
Clear all bits.
Definition Options.hh:148
OpenMesh::IO::Options::Options
Options()
Default constructor.
Definition Options.hh:121
OpenMesh::IO::Options::operator=
Options & operator=(const Options &_rhs)
Copy options defined in _rhs.
Definition Options.hh:160
OpenMesh::IO::Options::Flag
Flag
Definitions of Options for reading and writing.
Definition Options.hh:98
OpenMesh::IO::Options::ColorFloat
@ ColorFloat
Has (r) / store (w) float values for colors (currently only implemented for PLY and OFF files)
Definition Options.hh:112
OpenMesh::IO::Options::FaceNormal
@ FaceNormal
Has (r) / store (w) face normals.
Definition Options.hh:108
OpenMesh::IO::Options::TexCoordST
@ TexCoordST
Write texture coordinates as ST instead of UV.
Definition Options.hh:115
OpenMesh::IO::Options::Swap
@ Swap
Swap byte order in binary mode.
Definition Options.hh:103
OpenMesh::IO::Options::FaceColor
@ FaceColor
Has (r) / store (w) face colors.
Definition Options.hh:109
OpenMesh::IO::Options::FaceTexCoord
@ FaceTexCoord
Has (r) / store (w) face texture coordinates.
Definition Options.hh:110
OpenMesh::IO::Options::MSB
@ MSB
Assume big endian byte ordering.
Definition Options.hh:101
OpenMesh::IO::Options::Binary
@ Binary
Set binary mode for r/w.
Definition Options.hh:100
OpenMesh::IO::Options::Default
@ Default
No options.
Definition Options.hh:99
OpenMesh::IO::Options::Status
@ Status
Has (r) / store (w) status properties.
Definition Options.hh:114
OpenMesh::IO::Options::ColorAlpha
@ ColorAlpha
Has (r) / store (w) alpha values for colors.
Definition Options.hh:111
OpenMesh::IO::Options::LSB
@ LSB
Assume little endian byte ordering.
Definition Options.hh:102
OpenMesh::IO::Options::VertexNormal
@ VertexNormal
Has (r) / store (w) vertex normals.
Definition Options.hh:104
OpenMesh::IO::Options::VertexTexCoord
@ VertexTexCoord
Has (r) / store (w) texture coordinates.
Definition Options.hh:106
OpenMesh::IO::Options::EdgeColor
@ EdgeColor
Has (r) / store (w) edge colors.
Definition Options.hh:107
OpenMesh::IO::Options::VertexColor
@ VertexColor
Has (r) / store (w) vertex colors.
Definition Options.hh:105
OpenMesh::IO::Options::Custom
@ Custom
Has (r) custom properties (currently only implemented in PLY Reader ASCII version)
Definition Options.hh:113
OpenMesh::IO::Options::operator-=
Options & operator-=(const value_type _rhs)
Unset options defined in _rhs.
Definition Options.hh:172
OpenMesh::IO::Options::Options
Options(Flag _flg)
Initializing constructor setting a single option.
Definition Options.hh:131
OpenMesh::IO::Options::Options
Options(const Options &_opt)
Copy constructor.
Definition Options.hh:126