00001 /*===========================================================================*\ 00002 * * 00003 * OpenMesh * 00004 * Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen * 00005 * www.openmesh.org * 00006 * * 00007 *---------------------------------------------------------------------------* 00008 * This file is part of OpenMesh. * 00009 * * 00010 * OpenMesh is free software: you can redistribute it and/or modify * 00011 * it under the terms of the GNU Lesser General Public License as * 00012 * published by the Free Software Foundation, either version 3 of * 00013 * the License, or (at your option) any later version with the * 00014 * following exceptions: * 00015 * * 00016 * If other files instantiate templates or use macros * 00017 * or inline functions from this file, or you compile this file and * 00018 * link it with other files to produce an executable, this file does * 00019 * not by itself cause the resulting executable to be covered by the * 00020 * GNU Lesser General Public License. This exception does not however * 00021 * invalidate any other reasons why the executable file might be * 00022 * covered by the GNU Lesser General Public License. * 00023 * * 00024 * OpenMesh is distributed in the hope that it will be useful, * 00025 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00027 * GNU Lesser General Public License for more details. * 00028 * * 00029 * You should have received a copy of the GNU LesserGeneral Public * 00030 * License along with OpenMesh. If not, * 00031 * see <http://www.gnu.org/licenses/>. * 00032 * * 00033 \*===========================================================================*/ 00034 00035 /*===========================================================================*\ 00036 * * 00037 * $Revision: 137 $ * 00038 * $Date: 2009-06-04 10:46:29 +0200 (Do, 04. Jun 2009) $ * 00039 * * 00040 \*===========================================================================*/ 00041 00042 00043 //============================================================================= 00044 // 00045 // CLASS Status 00046 // 00047 //============================================================================= 00048 00049 00050 #ifndef OPENMESH_ATTRIBUTE_STATUS_HH 00051 #define OPENMESH_ATTRIBUTE_STATUS_HH 00052 00053 00054 //== INCLUDES ================================================================= 00055 00056 #include <OpenMesh/Core/System/config.h> 00057 00058 00059 //== NAMESPACES =============================================================== 00060 00061 00062 namespace OpenMesh { 00063 namespace Attributes { 00064 00065 00066 //== CLASS DEFINITION ======================================================== 00067 00068 00072 enum StatusBits { 00073 00074 DELETED = 1, 00075 LOCKED = 2, 00076 SELECTED = 4, 00077 HIDDEN = 8, 00078 FEATURE = 16, 00079 TAGGED = 32, 00080 TAGGED2 = 64, 00081 UNUSED = 128 00082 }; 00083 00084 00091 class StatusInfo 00092 { 00093 public: 00094 00095 typedef unsigned int value_type; 00096 00097 StatusInfo() : status_(0) {} 00098 00100 bool deleted() const { return is_bit_set(DELETED); } 00102 void set_deleted(bool _b) { change_bit(DELETED, _b); } 00103 00104 00106 bool locked() const { return is_bit_set(LOCKED); } 00108 void set_locked(bool _b) { change_bit(LOCKED, _b); } 00109 00110 00112 bool selected() const { return is_bit_set(SELECTED); } 00114 void set_selected(bool _b) { change_bit(SELECTED, _b); } 00115 00116 00118 bool hidden() const { return is_bit_set(HIDDEN); } 00120 void set_hidden(bool _b) { change_bit(HIDDEN, _b); } 00121 00122 00124 bool feature() const { return is_bit_set(FEATURE); } 00126 void set_feature(bool _b) { change_bit(FEATURE, _b); } 00127 00128 00130 bool tagged() const { return is_bit_set(TAGGED); } 00132 void set_tagged(bool _b) { change_bit(TAGGED, _b); } 00133 00134 00136 bool tagged2() const { return is_bit_set(TAGGED2); } 00138 void set_tagged2(bool _b) { change_bit(TAGGED2, _b); } 00139 00140 00142 unsigned int bits() const { return status_; } 00144 void set_bits(unsigned int _bits) { status_ = _bits; } 00145 00146 00148 bool is_bit_set(unsigned int _s) const { return (status_ & _s) > 0; } 00150 void set_bit(unsigned int _s) { status_ |= _s; } 00152 void unset_bit(unsigned int _s) { status_ &= ~_s; } 00154 void change_bit(unsigned int _s, bool _b) { 00155 if (_b) status_ |= _s; else status_ &= ~_s; } 00156 00157 00158 private: 00159 00160 value_type status_; 00161 }; 00162 00163 00164 //============================================================================= 00165 } // namespace Attributes 00166 } // namespace OpenMesh 00167 //============================================================================= 00168 #endif // OPENMESH_ATTRIBUTE_STATUS_HH defined 00169 //=============================================================================