OpenMesh
Loading...
Searching...
No Matches
VHierarchy.hh
1/* ========================================================================= *
2 * *
3 * OpenMesh *
4 * Copyright (c) 2001-2015, 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 * $Revision$ *
45 * $Date$ *
46 * *
47\*===========================================================================*/
48
49//=============================================================================
50//
51// CLASS newClass
52//
53//=============================================================================
54
55#ifndef OPENMESH_VDPROGMESH_VHIERARCHY_HH
56#define OPENMESH_VDPROGMESH_VHIERARCHY_HH
57
58
59//== INCLUDES =================================================================
60
61#include <vector>
62#include <OpenMesh/Tools/VDPM/VHierarchyNode.hh>
63
64
65//== FORWARDDECLARATIONS ======================================================
66
67
68//== NAMESPACES ===============================================================
69
70namespace OpenMesh {
71namespace VDPM {
72
73//== CLASS DEFINITION =========================================================
74
75
78class OPENMESHDLLEXPORT VHierarchy
79{
80public:
81
82 typedef unsigned int id_t;
83
84private:
85
87 unsigned int n_roots_;
88 unsigned char tree_id_bits_; // node_id_bits_ = 32-tree_id_bits_;
89
90public:
91
92 VHierarchy();
93
94 void clear() { nodes_.clear(); n_roots_ = 0; }
95 unsigned char tree_id_bits() const { return tree_id_bits_; }
96 unsigned int num_roots() const { return n_roots_; }
97 size_t num_nodes() const { return nodes_.size(); }
98
99 VHierarchyNodeIndex generate_node_index(id_t _tree_id, id_t _node_id)
100 {
101 return VHierarchyNodeIndex(_tree_id, _node_id, tree_id_bits_);
102 }
103
104
105 void set_num_roots(unsigned int _n_roots);
106
107 VHierarchyNodeHandle root_handle(unsigned int i) const
108 {
109 return VHierarchyNodeHandle( (int)i );
110 }
111
112
113 const VHierarchyNode& node(VHierarchyNodeHandle _vhierarchynode_handle) const
114 {
115 return nodes_[_vhierarchynode_handle.idx()];
116 }
117
118
119 VHierarchyNode& node(VHierarchyNodeHandle _vhierarchynode_handle)
120 {
121 return nodes_[_vhierarchynode_handle.idx()];
122 }
123
124 VHierarchyNodeHandle add_node();
125 VHierarchyNodeHandle add_node(const VHierarchyNode &_node);
126
127 void make_children(VHierarchyNodeHandle &_parent_handle);
128
129 bool is_ancestor(VHierarchyNodeIndex _ancestor_index,
130 VHierarchyNodeIndex _descendent_index);
131
132 bool is_leaf_node(VHierarchyNodeHandle _node_handle)
133 { return nodes_[_node_handle.idx()].is_leaf(); }
134
135 bool is_root_node(VHierarchyNodeHandle _node_handle)
136 { return nodes_[_node_handle.idx()].is_root(); }
137
138
139 const OpenMesh::Vec3f& normal(VHierarchyNodeHandle _node_handle) const
140 {
141 return nodes_[_node_handle.idx()].normal();
142 }
143
144 const VHierarchyNodeIndex&
145 node_index(VHierarchyNodeHandle _node_handle) const
146 { return nodes_[_node_handle.idx()].node_index(); }
147
148 VHierarchyNodeIndex& node_index(VHierarchyNodeHandle _node_handle)
149 { return nodes_[_node_handle.idx()].node_index(); }
150
151 const VHierarchyNodeIndex&
152 fund_lcut_index(VHierarchyNodeHandle _node_handle) const
153 { return nodes_[_node_handle.idx()].fund_lcut_index(); }
154
155 VHierarchyNodeIndex& fund_lcut_index(VHierarchyNodeHandle _node_handle)
156 { return nodes_[_node_handle.idx()].fund_lcut_index(); }
157
158 const VHierarchyNodeIndex&
159 fund_rcut_index(VHierarchyNodeHandle _node_handle) const
160 { return nodes_[_node_handle.idx()].fund_rcut_index(); }
161
162 VHierarchyNodeIndex& fund_rcut_index(VHierarchyNodeHandle _node_handle)
163 { return nodes_[_node_handle.idx()].fund_rcut_index(); }
164
165 VertexHandle vertex_handle(VHierarchyNodeHandle _node_handle)
166 { return nodes_[_node_handle.idx()].vertex_handle(); }
167
168 VHierarchyNodeHandle parent_handle(VHierarchyNodeHandle _node_handle)
169 { return nodes_[_node_handle.idx()].parent_handle(); }
170
171 VHierarchyNodeHandle lchild_handle(VHierarchyNodeHandle _node_handle)
172 { return nodes_[_node_handle.idx()].lchild_handle(); }
173
174 VHierarchyNodeHandle rchild_handle(VHierarchyNodeHandle _node_handle)
175 { return nodes_[_node_handle.idx()].rchild_handle(); }
176
177 VHierarchyNodeHandle node_handle(VHierarchyNodeIndex _node_index);
178
179private:
180
181 VHierarchyNodeHandle compute_dependency(VHierarchyNodeIndex index0,
182 VHierarchyNodeIndex index1);
183
184};
185
186
187
188//=============================================================================
189} // namespace VDPM
190} // namespace OpenMesh
191//=============================================================================
192#endif // OPENMESH_VDPROGMESH_VHIERARCHY_HH defined
193//=============================================================================
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:64
std::vector< VHierarchyNode > VHierarchyNodeContainer
Container for vertex hierarchy nodes.
Definition: VHierarchyNode.hh:185
Keeps the vertex hierarchy build during analyzing a progressive mesh.
Definition: VHierarchy.hh:79
unsigned int id_t
Type for tree and node ids.
Definition: VHierarchy.hh:82

Project OpenMesh, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .