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

Project OpenMesh, ©  Visual Computing Institute, RWTH Aachen. Documentation generated using doxygen .