| OpenMesh

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
VHierarchyNode.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_VHIERARCHYNODE_HH
56 #define OPENMESH_VDPROGMESH_VHIERARCHYNODE_HH
57
58
59 //== INCLUDES =================================================================
60
61
62 #include <vector>
63 #include <list>
64 #include <OpenMesh/Core/Geometry/VectorT.hh>
65 #include <OpenMesh/Core/Mesh/Handles.hh>
66 #include <OpenMesh/Tools/VDPM/VHierarchyNodeIndex.hh>
67
68
69 //== FORWARDDECLARATIONS ======================================================
70
71
72 //== NAMESPACES ===============================================================
73
74 namespace OpenMesh {
75 namespace VDPM {
76
77 //== CLASS DEFINITION =========================================================
78
79
82 struct VHierarchyNodeHandle : public BaseHandle
83 {
84 explicit VHierarchyNodeHandle(int _idx=-1) : BaseHandle(_idx) {}
85 };
86
87
89 static const VHierarchyNodeHandle InvalidVHierarchyNodeHandle;
90
91
95 class VHierarchyNode
96 {
97 public:
98
99 VHierarchyNode() { }
100
102 bool is_root() const
103 { return (parent_handle_.is_valid() == false) ? true : false; }
104
106 bool is_leaf() const
107 { return (lchild_handle_.is_valid() == false) ? true : false; }
108
110 VHierarchyNodeHandle parent_handle() { return parent_handle_; }
111
113 VHierarchyNodeHandle lchild_handle() { return lchild_handle_; }
114
116 VHierarchyNodeHandle rchild_handle()
117 { return VHierarchyNodeHandle(lchild_handle_.idx()+1); }
118
119 void set_parent_handle(VHierarchyNodeHandle _parent_handle)
120 { parent_handle_ = _parent_handle; }
121
122 void set_children_handle(VHierarchyNodeHandle _lchild_handle)
123 { lchild_handle_ = _lchild_handle; }
124
125 VertexHandle vertex_handle() const { return vh_; }
126 float radius() const { return radius_; }
127 const OpenMesh::Vec3f& normal() const { return normal_; }
128 float sin_square() const { return sin_square_; }
129 float mue_square() const { return mue_square_; }
130 float sigma_square() const { return sigma_square_; }
131
132 void set_vertex_handle(OpenMesh::VertexHandle _vh) { vh_ = _vh; }
133 void set_radius(float _radius) { radius_ = _radius; }
134 void set_normal(const OpenMesh::Vec3f &_normal) { normal_ = _normal; }
135
136 void set_sin_square(float _sin_square) { sin_square_ = _sin_square; }
137 void set_mue_square(float _mue_square) { mue_square_ = _mue_square; }
138 void set_sigma_square(float _sigma_square) { sigma_square_ = _sigma_square; }
139
140 void set_semi_angle(float _semi_angle)
141 { float f=sinf(_semi_angle); sin_square_ = f*f; }
142
143 void set_mue(float _mue) { mue_square_ = _mue * _mue; }
144 void set_sigma(float _sigma) { sigma_square_ = _sigma * _sigma; }
145
146 const VHierarchyNodeIndex& node_index() const { return node_index_; }
147 const VHierarchyNodeIndex& fund_lcut_index() const
148 { return fund_cut_node_index_[0]; }
149
150 const VHierarchyNodeIndex& fund_rcut_index() const
151 { return fund_cut_node_index_[1]; }
152
153 VHierarchyNodeIndex& node_index()
154 { return node_index_; }
155
156 VHierarchyNodeIndex& fund_lcut_index() { return fund_cut_node_index_[0]; }
157 VHierarchyNodeIndex& fund_rcut_index() { return fund_cut_node_index_[1]; }
158
159 void set_index(const VHierarchyNodeIndex &_node_index)
160 { node_index_ = _node_index; }
161
162 void set_fund_lcut(const VHierarchyNodeIndex &_node_index)
163 { fund_cut_node_index_[0] = _node_index; }
164
165 void set_fund_rcut(const VHierarchyNodeIndex &_node_index)
166 { fund_cut_node_index_[1] = _node_index; }
167
168 private:
169 VertexHandle vh_;
170 float radius_;
171 Vec3f normal_;
172 float sin_square_;
173 float mue_square_;
174 float sigma_square_;
175
176 VHierarchyNodeHandle parent_handle_;
177 VHierarchyNodeHandle lchild_handle_;
178
179
180 VHierarchyNodeIndex node_index_;
181 VHierarchyNodeIndex fund_cut_node_index_[2];
182 };
183
185 typedef std::vector<VHierarchyNode> VHierarchyNodeContainer;
186
188 typedef std::vector<VHierarchyNodeHandle> VHierarchyNodeHandleContainer;
189
191 typedef std::list<VHierarchyNodeHandle> VHierarchyNodeHandleList;
192
193
194 //=============================================================================
195 } // namesapce VDPM
196 } // namespace OpenMesh
197 //=============================================================================
198 #endif // OPENMESH_VDPROGMESH_VHIERARCHYNODE_HH defined
199 //=============================================================================
OpenMesh::BaseHandle
Base class for all handle types.
Definition: Handles.hh:67
OpenMesh::Vec3f
VectorT< float, 3 > Vec3f
3-float vector
Definition: Vector11T.hh:769
OpenMesh::BaseHandle::idx
int idx() const
Get the underlying index of this handle.
Definition: Handles.hh:74
OpenMesh::VDPM::VHierarchyNode::rchild_handle
VHierarchyNodeHandle rchild_handle()
Returns handle to right child.
Definition: VHierarchyNode.hh:116
OpenMesh::VDPM::VHierarchyNodeHandle
Handle for vertex hierarchy nodes.
Definition: VHierarchyNode.hh:82
OpenMesh::VertexHandle
Handle for a vertex entity.
Definition: Handles.hh:123
OpenMesh::VectorT< float, 3 >
OpenMesh::VDPM::VHierarchyNodeContainer
std::vector< VHierarchyNode > VHierarchyNodeContainer
Container for vertex hierarchy nodes.
Definition: VHierarchyNode.hh:185
OpenMesh::VDPM::VHierarchyNodeHandleList
std::list< VHierarchyNodeHandle > VHierarchyNodeHandleList
Container for vertex hierarchy node handles.
Definition: VHierarchyNode.hh:191
OpenMesh::BaseHandle::is_valid
bool is_valid() const
The handle is valid iff the index is not equal to -1.
Definition: Handles.hh:77
OpenMesh
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:64
OpenMesh::VDPM::VHierarchyNode::parent_handle
VHierarchyNodeHandle parent_handle()
Returns parent handle.
Definition: VHierarchyNode.hh:110
OpenMesh::VDPM::VHierarchyNode::lchild_handle
VHierarchyNodeHandle lchild_handle()
Returns handle to left child.
Definition: VHierarchyNode.hh:113
OpenMesh::VDPM::VHierarchyNodeHandleContainer
std::vector< VHierarchyNodeHandle > VHierarchyNodeHandleContainer
Container for vertex hierarchy node handles.
Definition: VHierarchyNode.hh:188
OpenMesh::VDPM::VHierarchyNode
Vertex hierarchy node.
Definition: VHierarchyNode.hh:95
OpenMesh::VDPM::VHierarchyNode::is_leaf
bool is_leaf() const
Returns true, if node is leaf else false.
Definition: VHierarchyNode.hh:106
OpenMesh::VDPM::VHierarchyNode::is_root
bool is_root() const
Returns true, if node is root else false.
Definition: VHierarchyNode.hh:102