OpenMesh
Options.hh
1/* ========================================================================= *
2 * *
3 * OpenMesh *
4 * Copyright (c) 2001-2025, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openmesh.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenMesh. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 * ========================================================================= */
41
42
43
44
45#ifndef OPENMESH_IO_OPTIONS_HH
46#define OPENMESH_IO_OPTIONS_HH
47
48
49//=== INCLUDES ================================================================
50
51
52// OpenMesh
53#include <OpenMesh/Core/System/config.h>
54#include <string>
55
56
57//== NAMESPACES ==============================================================
58
59
60namespace OpenMesh {
61namespace IO {
62
63
64//=== IMPLEMENTATION ==========================================================
65
66
71
72
73//-----------------------------------------------------------------------------
74
92{
93public:
94 typedef int enum_type;
95 typedef enum_type value_type;
96
99 enum Flag {
100 None = 0x0000,
101 Binary = 0x0001,
102 MSB = 0x0002,
103 LSB = 0x0004,
104 Swap = 0x0008,
105 VertexNormal = 0x0010,
106 VertexColor = 0x0020,
107 VertexTexCoord = 0x0040,
108 EdgeColor = 0x0080,
109 FaceNormal = 0x0100,
110 FaceColor = 0x0200,
111 FaceTexCoord = 0x0400,
112 ColorAlpha = 0x0800,
113 ColorFloat = 0x1000,
114 Custom = 0x2000,
115 Status = 0x4000,
116 TexCoordST = 0x8000,
118 };
119
122 std::string texture_file ;
123
127
128public:
129
132 { }
133
135 Options(const value_type _flgs) : flags_( _flgs)
136 { }
137
139 void cleanup(void)
140 { flags_ = Default; }
141
143 void clear(void)
144 { flags_ = 0; }
145
147 bool is_empty(void) const { return !flags_; }
148
149public:
150
151
152 Options& operator = ( const value_type _rhs )
153 { flags_ = _rhs; return *this; }
154
155
157
158
159 Options& operator -= ( const value_type _rhs )
160 { flags_ &= ~_rhs; return *this; }
161
162 Options& unset( const value_type _rhs)
163 { return (*this -= _rhs); }
164
166
167
168
170
171
172 Options& operator += ( const value_type _rhs )
173 { flags_ |= _rhs; return *this; }
174
175 Options& set( const value_type _rhs)
176 { return (*this += _rhs); }
177
179
180public:
181
182
183 // Check if an option or several options are set.
184 bool check(const value_type _rhs) const
185 {
186 return (flags_ & _rhs)==_rhs;
187 }
188
189 bool is_binary() const { return check(Binary); }
190 bool vertex_has_normal() const { return check(VertexNormal); }
191 bool vertex_has_color() const { return check(VertexColor); }
192 bool vertex_has_texcoord() const { return check(VertexTexCoord); }
193 bool vertex_has_status() const { return check(Status); }
194 bool edge_has_color() const { return check(EdgeColor); }
195 bool edge_has_status() const { return check(Status); }
196 bool halfedge_has_status() const { return check(Status); }
197 bool face_has_normal() const { return check(FaceNormal); }
198 bool face_has_color() const { return check(FaceColor); }
199 bool face_has_texcoord() const { return check(FaceTexCoord); }
200 bool face_has_status() const { return check(Status); }
201 bool color_has_alpha() const { return check(ColorAlpha); }
202 bool color_is_float() const { return check(ColorFloat); }
203 bool use_st_coordinates() const { return check(TexCoordST); }
204
205
207 bool operator == (const value_type _rhs) const
208 { return flags_ == _rhs; }
209
210
212 bool operator != (const value_type _rhs) const
213 { return flags_ != _rhs; }
214
215
217 operator value_type () const { return flags_; }
218
219private:
220
221 bool operator && (const value_type _rhs) const;
222
223 value_type flags_;
224};
225
226//-----------------------------------------------------------------------------
227
228
229
230
232
233
234//=============================================================================
235} // namespace IO
236} // namespace OpenMesh
237//=============================================================================
238#endif
239//=============================================================================
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:59
Set options for reader/writer modules.
Definition: Options.hh:92
Options & operator+=(const value_type _rhs)
Set options defined in _rhs.
Definition: Options.hh:172
std::string material_file_extension
Filename extension for material files when writing OBJs default is currently .mat.
Definition: Options.hh:126
Options(const value_type _flgs)
Initializing constructor setting multiple options.
Definition: Options.hh:135
bool operator!=(const value_type _rhs) const
Returns true if _rhs does not have the same options enabled.
Definition: Options.hh:212
void cleanup(void)
Restore state after default constructor.
Definition: Options.hh:139
bool is_empty(void) const
Returns true if all bits are zero.
Definition: Options.hh:147
bool operator==(const value_type _rhs) const
Returns true if _rhs has the same options enabled.
Definition: Options.hh:207
void clear(void)
Clear all bits.
Definition: Options.hh:143
Options()
Default constructor.
Definition: Options.hh:131
Flag
Definitions of Options for reading and writing.
Definition: Options.hh:99
@ ColorFloat
Has (r) / store (w) float values for colors (currently only implemented for PLY and OFF files)
Definition: Options.hh:113
@ FaceNormal
Has (r) / store (w) face normals.
Definition: Options.hh:109
@ TexCoordST
Write texture coordinates as ST instead of UV.
Definition: Options.hh:116
@ Swap
Swap byte order in binary mode.
Definition: Options.hh:104
@ None
No options.
Definition: Options.hh:100
@ FaceColor
Has (r) / store (w) face colors.
Definition: Options.hh:110
@ FaceTexCoord
Has (r) / store (w) face texture coordinates.
Definition: Options.hh:111
@ MSB
Assume big endian byte ordering.
Definition: Options.hh:102
@ Binary
Set binary mode for r/w.
Definition: Options.hh:101
@ Default
By default write persistent custom properties.
Definition: Options.hh:117
@ Status
Has (r) / store (w) status properties.
Definition: Options.hh:115
@ ColorAlpha
Has (r) / store (w) alpha values for colors.
Definition: Options.hh:112
@ LSB
Assume little endian byte ordering.
Definition: Options.hh:103
@ VertexNormal
Has (r) / store (w) vertex normals.
Definition: Options.hh:105
@ VertexTexCoord
Has (r) / store (w) texture coordinates.
Definition: Options.hh:107
@ EdgeColor
Has (r) / store (w) edge colors.
Definition: Options.hh:108
@ VertexColor
Has (r) / store (w) vertex colors.
Definition: Options.hh:106
@ Custom
Has (r) / store (w) custom properties marked persistent (currently PLY only supports reading and only...
Definition: Options.hh:114
std::string texture_file
Texture filename.
Definition: Options.hh:122
Options & operator-=(const value_type _rhs)
Unset options defined in _rhs.
Definition: Options.hh:159

Project OpenMesh, ©  Visual Computing Institute, RWTH Aachen. Documentation generated using doxygen .