OpenMesh

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Status.hh
1 /*===========================================================================*\
2 * *
3 * OpenMesh *
4 * Copyright (C) 2001-2012 by Computer Graphics Group, RWTH Aachen *
5 * www.openmesh.org *
6 * *
7 *---------------------------------------------------------------------------*
8 * This file is part of OpenMesh. *
9 * *
10 * OpenMesh is free software: you can redistribute it and/or modify *
11 * it under the terms of the GNU Lesser General Public License as *
12 * published by the Free Software Foundation, either version 3 of *
13 * the License, or (at your option) any later version with the *
14 * following exceptions: *
15 * *
16 * If other files instantiate templates or use macros *
17 * or inline functions from this file, or you compile this file and *
18 * link it with other files to produce an executable, this file does *
19 * not by itself cause the resulting executable to be covered by the *
20 * GNU Lesser General Public License. This exception does not however *
21 * invalidate any other reasons why the executable file might be *
22 * covered by the GNU Lesser General Public License. *
23 * *
24 * OpenMesh is distributed in the hope that it will be useful, *
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
27 * GNU Lesser General Public License for more details. *
28 * *
29 * You should have received a copy of the GNU LesserGeneral Public *
30 * License along with OpenMesh. If not, *
31 * see <http://www.gnu.org/licenses/>. *
32 * *
33 \*===========================================================================*/
34
35 /*===========================================================================*\
36 * *
37 * $Revision: 736 $ *
38 * $Date: 2012-10-08 09:30:49 +0200 (Mo, 08. Okt 2012) $ *
39 * *
40 \*===========================================================================*/
41
42
43 //=============================================================================
44 //
45 // CLASS Status
46 //
47 //=============================================================================
48
49
50 #ifndef OPENMESH_ATTRIBUTE_STATUS_HH
51 #define OPENMESH_ATTRIBUTE_STATUS_HH
52
53
54 //== INCLUDES =================================================================
55
56 #include <OpenMesh/Core/System/config.h>
57
58
59 //== NAMESPACES ===============================================================
60
61
62 namespace OpenMesh {
63 namespace Attributes {
64
65
66 //== CLASS DEFINITION ========================================================
67
68
72 enum StatusBits {
73
74 DELETED = 1,
75 LOCKED = 2,
76 SELECTED = 4,
77 HIDDEN = 8,
78 FEATURE = 16,
79 TAGGED = 32,
80 TAGGED2 = 64,
81 FIXEDNONMANIFOLD = 128,
82 UNUSED = 256
83 };
84
85
92 class StatusInfo
93 {
94 public:
95
96 typedef unsigned int value_type;
97
98 StatusInfo() : status_(0) {}
99
101 bool deleted() const { return is_bit_set(DELETED); }
103 void set_deleted(bool _b) { change_bit(DELETED, _b); }
104
105
107 bool locked() const { return is_bit_set(LOCKED); }
109 void set_locked(bool _b) { change_bit(LOCKED, _b); }
110
111
113 bool selected() const { return is_bit_set(SELECTED); }
115 void set_selected(bool _b) { change_bit(SELECTED, _b); }
116
117
119 bool hidden() const { return is_bit_set(HIDDEN); }
121 void set_hidden(bool _b) { change_bit(HIDDEN, _b); }
122
123
125 bool feature() const { return is_bit_set(FEATURE); }
127 void set_feature(bool _b) { change_bit(FEATURE, _b); }
128
129
131 bool tagged() const { return is_bit_set(TAGGED); }
133 void set_tagged(bool _b) { change_bit(TAGGED, _b); }
134
135
137 bool tagged2() const { return is_bit_set(TAGGED2); }
139 void set_tagged2(bool _b) { change_bit(TAGGED2, _b); }
140
141
143 bool fixed_nonmanifold() const { return is_bit_set(FIXEDNONMANIFOLD); }
145 void set_fixed_nonmanifold(bool _b) { change_bit(FIXEDNONMANIFOLD, _b); }
146
147
149 unsigned int bits() const { return status_; }
151 void set_bits(unsigned int _bits) { status_ = _bits; }
152
153
155 bool is_bit_set(unsigned int _s) const { return (status_ & _s) > 0; }
157 void set_bit(unsigned int _s) { status_ |= _s; }
159 void unset_bit(unsigned int _s) { status_ &= ~_s; }
161 void change_bit(unsigned int _s, bool _b) {
162 if (_b) status_ |= _s; else status_ &= ~_s; }
163
164
165 private:
166
167 value_type status_;
168 };
169
170
171 //=============================================================================
172 } // namespace Attributes
173 } // namespace OpenMesh
174 //=============================================================================
175 #endif // OPENMESH_ATTRIBUTE_STATUS_HH defined
176 //=============================================================================