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
VHierarchyNodeIndex.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 // CLASS newClass
45 //
46 //=============================================================================
47
48 #ifndef OPENMESH_VDPROGMESH_VHIERARCHYNODEINDEX_HH
49 #define OPENMESH_VDPROGMESH_VHIERARCHYNODEINDEX_HH
50
51 //== INCLUDES =================================================================
52
53 #include <vector>
54 #include <cassert>
55
56 //== FORWARDDECLARATIONS ======================================================
57
58
59 //== NAMESPACES ===============================================================
60
61 namespace OpenMesh {
62 namespace VDPM {
63
64 //== CLASS DEFINITION =========================================================
65
66
71 class VHierarchyNodeIndex
72 {
73 private:
74 unsigned int value_;
75
76 public:
77
78 static const VHierarchyNodeIndex InvalidIndex;
79
80 public:
81
82 VHierarchyNodeIndex()
83 { value_ = 0; }
84
85 VHierarchyNodeIndex(unsigned int _value)
86 { value_ = _value; }
87
88 VHierarchyNodeIndex(const VHierarchyNodeIndex &_other)
89 { value_ = _other.value_; }
90
91 VHierarchyNodeIndex(unsigned int _tree_id,
92 unsigned int _node_id,
93 unsigned short _tree_id_bits)
94 {
95 assert(_tree_id < ((unsigned int) 0x00000001 << _tree_id_bits));
96 assert(_node_id < ((unsigned int) 0x00000001 << (32 - _tree_id_bits)));
97 value_ = (_tree_id << (32 - _tree_id_bits)) | _node_id;
98 }
99
100 bool is_valid(unsigned short _tree_id_bits) const
101 { return node_id(_tree_id_bits) != 0 ? true : false; }
102
103 unsigned int tree_id(unsigned short _tree_id_bits) const
104 { return value_ >> (32 - _tree_id_bits); }
105
106 unsigned int node_id(unsigned short _tree_id_bits) const
107 { return value_ & ((unsigned int) 0xFFFFFFFF >> _tree_id_bits); }
108
109 bool operator< (const VHierarchyNodeIndex &other) const
110 { return (value_ < other.value_) ? true : false; }
111
112 unsigned int value() const
113 { return value_; }
114 };
115
116
118 typedef std::vector<VHierarchyNodeIndex> VHierarchyNodeIndexContainer;
119
120
121 //=============================================================================
122 } // namespace VDPM
123 } // namespace OpenMesh
124 //=============================================================================
125 #endif // OPENMESH_VDPROGMESH_VHIERARCHYNODEINDEX_HH defined
126 //=============================================================================
OpenMesh::VDPM::VHierarchyNodeIndex
Index of vertex hierarchy node.
Definition: VHierarchyNodeIndex.hh:71
OpenMesh::VDPM::VHierarchyNodeIndexContainer
std::vector< VHierarchyNodeIndex > VHierarchyNodeIndexContainer
Container for vertex hierarchy node indices.
Definition: VHierarchyNodeIndex.hh:118