2015-04-28 11:54:17 +00:00
|
|
|
/* ========================================================================= *
|
2009-02-06 13:37:46 +00:00
|
|
|
* *
|
|
|
|
|
* OpenMesh *
|
2015-04-28 11:33:32 +00:00
|
|
|
* Copyright (c) 2001-2015, RWTH-Aachen University *
|
2015-04-28 13:07:46 +00:00
|
|
|
* Department of Computer Graphics and Multimedia *
|
2015-04-28 11:33:32 +00:00
|
|
|
* All rights reserved. *
|
|
|
|
|
* www.openmesh.org *
|
2009-02-06 13:37:46 +00:00
|
|
|
* *
|
2013-02-27 13:30:37 +00:00
|
|
|
*---------------------------------------------------------------------------*
|
2015-04-28 11:33:32 +00:00
|
|
|
* This file is part of OpenMesh. *
|
|
|
|
|
*---------------------------------------------------------------------------*
|
2009-02-06 13:37:46 +00:00
|
|
|
* *
|
2015-04-28 11:33:32 +00:00
|
|
|
* Redistribution and use in source and binary forms, with or without *
|
|
|
|
|
* modification, are permitted provided that the following conditions *
|
|
|
|
|
* are met: *
|
2009-02-06 13:37:46 +00:00
|
|
|
* *
|
2015-04-28 11:33:32 +00:00
|
|
|
* 1. Redistributions of source code must retain the above copyright notice, *
|
|
|
|
|
* this list of conditions and the following disclaimer. *
|
2009-02-06 13:37:46 +00:00
|
|
|
* *
|
2015-04-28 11:33:32 +00:00
|
|
|
* 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. *
|
2009-02-06 13:37:46 +00:00
|
|
|
* *
|
2015-04-28 11:33:32 +00:00
|
|
|
* 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. *
|
2009-06-04 08:46:29 +00:00
|
|
|
* *
|
2015-04-28 11:33:32 +00:00
|
|
|
* 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. *
|
2015-04-28 11:54:17 +00:00
|
|
|
* *
|
|
|
|
|
* ========================================================================= */
|
2009-06-04 08:46:29 +00:00
|
|
|
|
|
|
|
|
/*===========================================================================*\
|
2013-02-27 13:30:37 +00:00
|
|
|
* *
|
2009-06-04 08:46:29 +00:00
|
|
|
* $Revision$ *
|
|
|
|
|
* $Date$ *
|
2009-02-06 13:37:46 +00:00
|
|
|
* *
|
|
|
|
|
\*===========================================================================*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef OPENMESH_IO_OPTIONS_HH
|
|
|
|
|
#define OPENMESH_IO_OPTIONS_HH
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//=== INCLUDES ================================================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// OpenMesh
|
|
|
|
|
#include <OpenMesh/Core/System/config.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//== NAMESPACES ==============================================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace OpenMesh {
|
|
|
|
|
namespace IO {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//=== IMPLEMENTATION ==========================================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** \name Mesh Reading / Writing
|
|
|
|
|
Option for reader and writer modules.
|
|
|
|
|
*/
|
|
|
|
|
//@{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/** \brief Set options for reader/writer modules.
|
|
|
|
|
*
|
2013-02-27 13:30:37 +00:00
|
|
|
* The class is used in a twofold way.
|
|
|
|
|
* -# In combination with reader modules the class is used
|
2009-02-06 13:37:46 +00:00
|
|
|
* - to pass hints to the reading module, whether the input is
|
|
|
|
|
* binary and what byte ordering the binary data has
|
|
|
|
|
* - to retrieve information about the file contents after
|
|
|
|
|
* succesful reading.
|
|
|
|
|
* -# In combination with write modules the class gives directions to
|
2013-02-27 13:30:37 +00:00
|
|
|
* the writer module, whether to
|
2009-02-06 13:37:46 +00:00
|
|
|
* - use binary mode or not and what byte order to use
|
|
|
|
|
* - store one of the standard properties.
|
|
|
|
|
*
|
2013-02-27 13:30:37 +00:00
|
|
|
* The option are defined in \c Options::Flag as bit values and stored in
|
2009-02-06 13:37:46 +00:00
|
|
|
* an \c int value as a bitset.
|
|
|
|
|
*/
|
|
|
|
|
class Options
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
typedef int enum_type;
|
|
|
|
|
typedef enum_type value_type;
|
2013-02-27 13:30:37 +00:00
|
|
|
|
2009-02-06 13:37:46 +00:00
|
|
|
/// Definitions of %Options for reading and writing. The options can be
|
|
|
|
|
/// or'ed.
|
|
|
|
|
enum Flag {
|
2010-01-22 10:06:05 +00:00
|
|
|
Default = 0x0000, ///< No options
|
|
|
|
|
Binary = 0x0001, ///< Set binary mode for r/w
|
|
|
|
|
MSB = 0x0002, ///< Assume big endian byte ordering
|
|
|
|
|
LSB = 0x0004, ///< Assume little endian byte ordering
|
|
|
|
|
Swap = 0x0006, ///< Swap byte order in binary mode
|
|
|
|
|
VertexNormal = 0x0010, ///< Has (r) / store (w) vertex normals
|
|
|
|
|
VertexColor = 0x0020, ///< Has (r) / store (w) vertex colors
|
|
|
|
|
VertexTexCoord = 0x0040, ///< Has (r) / store (w) texture coordinates
|
2010-01-22 10:07:21 +00:00
|
|
|
EdgeColor = 0x0080, ///< Has (r) / store (w) edge colors
|
2010-01-22 10:06:05 +00:00
|
|
|
FaceNormal = 0x0100, ///< Has (r) / store (w) face normals
|
|
|
|
|
FaceColor = 0x0200, ///< Has (r) / store (w) face colors
|
2012-10-08 09:45:20 +00:00
|
|
|
FaceTexCoord = 0x0400, ///< Has (r) / store (w) face texture coordinates
|
2014-10-24 08:52:07 +00:00
|
|
|
ColorAlpha = 0x0800, ///< Has (r) / store (w) alpha values for colors
|
|
|
|
|
ColorFloat = 0x1000, ///< Has (r) / store (w) float values for colors (currently only implemented for PLY and OFF files)
|
|
|
|
|
Custom = 0x2000 ///< Has (r) custom properties (currently only implemented in PLY Reader ASCII version)
|
2009-02-06 13:37:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
/// Default constructor
|
|
|
|
|
Options() : flags_( Default )
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Copy constructor
|
|
|
|
|
Options(const Options& _opt) : flags_(_opt.flags_)
|
|
|
|
|
{ }
|
2013-02-27 13:30:37 +00:00
|
|
|
|
2009-02-06 13:37:46 +00:00
|
|
|
|
|
|
|
|
/// Initializing constructor setting a single option
|
|
|
|
|
Options(Flag _flg) : flags_( _flg)
|
|
|
|
|
{ }
|
|
|
|
|
|
2013-02-27 13:30:37 +00:00
|
|
|
|
2009-02-06 13:37:46 +00:00
|
|
|
/// Initializing constructor setting multiple options
|
|
|
|
|
Options(const value_type _flgs) : flags_( _flgs)
|
|
|
|
|
{ }
|
|
|
|
|
|
2013-02-27 13:30:37 +00:00
|
|
|
|
2009-02-06 13:37:46 +00:00
|
|
|
~Options()
|
|
|
|
|
{ }
|
2013-02-27 13:30:37 +00:00
|
|
|
|
2009-02-06 13:37:46 +00:00
|
|
|
/// Restore state after default constructor.
|
|
|
|
|
void cleanup(void)
|
|
|
|
|
{ flags_ = Default; }
|
|
|
|
|
|
|
|
|
|
/// Clear all bits.
|
|
|
|
|
void clear(void)
|
|
|
|
|
{ flags_ = 0; }
|
|
|
|
|
|
|
|
|
|
/// Returns true if all bits are zero.
|
|
|
|
|
bool is_empty(void) const { return !flags_; }
|
|
|
|
|
|
|
|
|
|
public:
|
2013-02-27 13:30:37 +00:00
|
|
|
|
2009-02-06 13:37:46 +00:00
|
|
|
|
|
|
|
|
//@{
|
|
|
|
|
/// Copy options defined in _rhs.
|
|
|
|
|
|
|
|
|
|
Options& operator = ( const Options& _rhs )
|
|
|
|
|
{ flags_ = _rhs.flags_; return *this; }
|
|
|
|
|
|
|
|
|
|
Options& operator = ( const value_type _rhs )
|
|
|
|
|
{ flags_ = _rhs; return *this; }
|
|
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
2013-02-27 13:30:37 +00:00
|
|
|
|
2009-02-06 13:37:46 +00:00
|
|
|
//@{
|
|
|
|
|
/// Unset options defined in _rhs.
|
|
|
|
|
|
|
|
|
|
Options& operator -= ( const value_type _rhs )
|
|
|
|
|
{ flags_ &= ~_rhs; return *this; }
|
|
|
|
|
|
|
|
|
|
Options& unset( const value_type _rhs)
|
2013-02-27 13:30:37 +00:00
|
|
|
{ return (*this -= _rhs); }
|
2009-02-06 13:37:46 +00:00
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
2013-02-27 13:30:37 +00:00
|
|
|
|
2009-02-06 13:37:46 +00:00
|
|
|
|
|
|
|
|
//@{
|
|
|
|
|
/// Set options defined in _rhs
|
2013-02-27 13:30:37 +00:00
|
|
|
|
2009-02-06 13:37:46 +00:00
|
|
|
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;
|
|
|
|
|
}
|
2013-02-27 13:30:37 +00:00
|
|
|
|
2009-02-06 13:37:46 +00:00
|
|
|
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); }
|
2010-01-21 14:40:03 +00:00
|
|
|
bool edge_has_color() const { return check(EdgeColor); }
|
2009-02-06 13:37:46 +00:00
|
|
|
bool face_has_normal() const { return check(FaceNormal); }
|
|
|
|
|
bool face_has_color() const { return check(FaceColor); }
|
2012-10-08 09:45:20 +00:00
|
|
|
bool face_has_texcoord() const { return check(FaceTexCoord); }
|
2009-02-06 13:37:46 +00:00
|
|
|
bool color_has_alpha() const { return check(ColorAlpha); }
|
2013-02-27 13:30:37 +00:00
|
|
|
bool color_is_float() const { return check(ColorFloat); }
|
2009-02-06 13:37:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Returns true if _rhs has the same options enabled.
|
|
|
|
|
bool operator == (const value_type _rhs) const
|
|
|
|
|
{ return flags_ == _rhs; }
|
2013-02-27 13:30:37 +00:00
|
|
|
|
2009-02-06 13:37:46 +00:00
|
|
|
|
|
|
|
|
/// Returns true if _rhs does not have the same options enabled.
|
|
|
|
|
bool operator != (const value_type _rhs) const
|
|
|
|
|
{ return flags_ != _rhs; }
|
2013-02-27 13:30:37 +00:00
|
|
|
|
2009-02-06 13:37:46 +00:00
|
|
|
|
|
|
|
|
/// Returns the option set.
|
|
|
|
|
operator value_type () const { return flags_; }
|
2013-02-27 13:30:37 +00:00
|
|
|
|
2009-02-06 13:37:46 +00:00
|
|
|
private:
|
2013-02-27 13:30:37 +00:00
|
|
|
|
2009-02-06 13:37:46 +00:00
|
|
|
bool operator && (const value_type _rhs) const;
|
2013-02-27 13:30:37 +00:00
|
|
|
|
2009-02-06 13:37:46 +00:00
|
|
|
value_type flags_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
} // namespace IO
|
|
|
|
|
} // namespace OpenMesh
|
|
|
|
|
//=============================================================================
|
|
|
|
|
#endif
|
|
|
|
|
//=============================================================================
|