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-2014 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: 990 $ *
38 * $Date: 2014-02-05 10:01:07 +0100 (Mi, 05. Feb 2014) $ *
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 //=============================================================================
OpenMesh::Attributes::TAGGED
Item is tagged.
Definition: Status.hh:79
OpenMesh::Attributes::StatusInfo::set_tagged
void set_tagged(bool _b)
set tagged
Definition: Status.hh:133
OpenMesh::Attributes::TAGGED2
Alternate bit for tagging an item.
Definition: Status.hh:80
OpenMesh::Attributes::StatusInfo::change_bit
void change_bit(unsigned int _s, bool _b)
set or unset a certain bit
Definition: Status.hh:161
OpenMesh::Attributes::StatusInfo::set_feature
void set_feature(bool _b)
set feature
Definition: Status.hh:127
OpenMesh::Attributes::StatusInfo::set_locked
void set_locked(bool _b)
set locked
Definition: Status.hh:109
OpenMesh::Attributes::StatusInfo::set_hidden
void set_hidden(bool _b)
set hidden
Definition: Status.hh:121
OpenMesh::Attributes::StatusInfo::set_tagged2
void set_tagged2(bool _b)
set tagged
Definition: Status.hh:139
OpenMesh::Attributes::StatusInfo::set_selected
void set_selected(bool _b)
set selected
Definition: Status.hh:115
OpenMesh::Attributes::StatusInfo
Add status information to a base class.
Definition: Status.hh:92
OpenMesh::Attributes::StatusInfo::fixed_nonmanifold
bool fixed_nonmanifold() const
is fixed non-manifold ?
Definition: Status.hh:143
OpenMesh::Attributes::StatusInfo::set_deleted
void set_deleted(bool _b)
set deleted
Definition: Status.hh:103
OpenMesh::Attributes::StatusInfo::set_bits
void set_bits(unsigned int _bits)
set whole status at once
Definition: Status.hh:151
OpenMesh::Attributes::StatusInfo::locked
bool locked() const
is locked ?
Definition: Status.hh:107
OpenMesh::Attributes::HIDDEN
Item is hidden.
Definition: Status.hh:77
OpenMesh::Attributes::DELETED
Item has been deleted.
Definition: Status.hh:74
OpenMesh::Attributes::LOCKED
Item is locked.
Definition: Status.hh:75
OpenMesh::Attributes::StatusInfo::is_bit_set
bool is_bit_set(unsigned int _s) const
is a certain bit set ?
Definition: Status.hh:155
OpenMesh::Attributes::StatusBits
StatusBits
Status bits used by the Status class.
Definition: Status.hh:72
OpenMesh::Attributes::FIXEDNONMANIFOLD
Item was non-two-manifold and had to be fixed.
Definition: Status.hh:81
OpenMesh::Attributes::StatusInfo::bits
unsigned int bits() const
return whole status
Definition: Status.hh:149
OpenMesh::Attributes::StatusInfo::set_fixed_nonmanifold
void set_fixed_nonmanifold(bool _b)
set fixed non-manifold
Definition: Status.hh:145
OpenMesh::Attributes::StatusInfo::deleted
bool deleted() const
is deleted ?
Definition: Status.hh:101
OpenMesh::Attributes::UNUSED
Unused.
Definition: Status.hh:82
OpenMesh::Attributes::SELECTED
Item is selected.
Definition: Status.hh:76
OpenMesh::Attributes::StatusInfo::tagged
bool tagged() const
is tagged ?
Definition: Status.hh:131
OpenMesh::Attributes::FEATURE
Item is a feature or belongs to a feature.
Definition: Status.hh:78
OpenMesh::Attributes::StatusInfo::tagged2
bool tagged2() const
is tagged2 ? This is just one more tag info.
Definition: Status.hh:137
OpenMesh::Attributes::StatusInfo::set_bit
void set_bit(unsigned int _s)
set a certain bit
Definition: Status.hh:157
OpenMesh::Attributes::StatusInfo::feature
bool feature() const
is feature ?
Definition: Status.hh:125
OpenMesh::Attributes::StatusInfo::unset_bit
void unset_bit(unsigned int _s)
unset a certain bit
Definition: Status.hh:159
OpenMesh::Attributes::StatusInfo::selected
bool selected() const
is selected ?
Definition: Status.hh:113
OpenMesh::Attributes::StatusInfo::hidden
bool hidden() const
is hidden ?
Definition: Status.hh:119