| OpenMesh

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 //=============================================================================
45 //
46 // CLASS newClass
47 //
48 //=============================================================================
49
50 #ifndef OPENMESH_VDPROGMESH_VHIERARCHYNODE_HH
51 #define OPENMESH_VDPROGMESH_VHIERARCHYNODE_HH
52
53
54 //== INCLUDES =================================================================
55
56
57 #include <vector>
58 #include <list>
59 #include <OpenMesh/Core/Geometry/VectorT.hh>
60 #include <OpenMesh/Core/Mesh/Handles.hh>
61 #include <OpenMesh/Tools/VDPM/VHierarchyNodeIndex.hh>
62
63
64 //== FORWARDDECLARATIONS ======================================================
65
66
67 //== NAMESPACES ===============================================================
68
69 namespace OpenMesh {
70 namespace VDPM {
71
72 //== CLASS DEFINITION =========================================================
73
74
77 struct VHierarchyNodeHandle : public BaseHandle
78 {
79 explicit VHierarchyNodeHandle(int _idx=-1) : BaseHandle(_idx) {}
80 };
81
82
84 static const VHierarchyNodeHandle InvalidVHierarchyNodeHandle;
85
86
90 class VHierarchyNode
91 {
92 public:
93
94 VHierarchyNode() :radius_(0.0f), normal_(0.0f), sin_square_(0.0f),mue_square_(0.0f), sigma_square_(0.0f) { }
95
97 bool is_root() const
98 { return (parent_handle_.is_valid() == false) ? true : false; }
99
101 bool is_leaf() const
102 { return (lchild_handle_.is_valid() == false) ? true : false; }
103
105 VHierarchyNodeHandle parent_handle() { return parent_handle_; }
106
108 VHierarchyNodeHandle lchild_handle() { return lchild_handle_; }
109
111 VHierarchyNodeHandle rchild_handle()
112 { return VHierarchyNodeHandle(lchild_handle_.idx()+1); }
113
114 void set_parent_handle(VHierarchyNodeHandle _parent_handle)
115 { parent_handle_ = _parent_handle; }
116
117 void set_children_handle(VHierarchyNodeHandle _lchild_handle)
118 { lchild_handle_ = _lchild_handle; }
119
120 VertexHandle vertex_handle() const { return vh_; }
121 float radius() const { return radius_; }
122 const OpenMesh::Vec3f& normal() const { return normal_; }
123 float sin_square() const { return sin_square_; }
124 float mue_square() const { return mue_square_; }
125 float sigma_square() const { return sigma_square_; }
126
127 void set_vertex_handle(OpenMesh::VertexHandle _vh) { vh_ = _vh; }
128 void set_radius(float _radius) { radius_ = _radius; }
129 void set_normal(const OpenMesh::Vec3f &_normal) { normal_ = _normal; }
130
131 void set_sin_square(float _sin_square) { sin_square_ = _sin_square; }
132 void set_mue_square(float _mue_square) { mue_square_ = _mue_square; }
133 void set_sigma_square(float _sigma_square) { sigma_square_ = _sigma_square; }
134
135 void set_semi_angle(float _semi_angle)
136 { float f=sinf(_semi_angle); sin_square_ = f*f; }
137
138 void set_mue(float _mue) { mue_square_ = _mue * _mue; }
139 void set_sigma(float _sigma) { sigma_square_ = _sigma * _sigma; }
140
141 const VHierarchyNodeIndex& node_index() const { return node_index_; }
142 const VHierarchyNodeIndex& fund_lcut_index() const
143 { return fund_cut_node_index_[0]; }
144
145 const VHierarchyNodeIndex& fund_rcut_index() const
146 { return fund_cut_node_index_[1]; }
147
148 VHierarchyNodeIndex& node_index()
149 { return node_index_; }
150
151 VHierarchyNodeIndex& fund_lcut_index() { return fund_cut_node_index_[0]; }
152 VHierarchyNodeIndex& fund_rcut_index() { return fund_cut_node_index_[1]; }
153
154 void set_index(const VHierarchyNodeIndex &_node_index)
155 { node_index_ = _node_index; }
156
157 void set_fund_lcut(const VHierarchyNodeIndex &_node_index)
158 { fund_cut_node_index_[0] = _node_index; }
159
160 void set_fund_rcut(const VHierarchyNodeIndex &_node_index)
161 { fund_cut_node_index_[1] = _node_index; }
162
163 private:
164 VertexHandle vh_;
165 float radius_;
166 Vec3f normal_;
167 float sin_square_;
168 float mue_square_;
169 float sigma_square_;
170
171 VHierarchyNodeHandle parent_handle_;
172 VHierarchyNodeHandle lchild_handle_;
173
174
175 VHierarchyNodeIndex node_index_;
176 VHierarchyNodeIndex fund_cut_node_index_[2];
177 };
178
180 typedef std::vector<VHierarchyNode> VHierarchyNodeContainer;
181
183 typedef std::vector<VHierarchyNodeHandle> VHierarchyNodeHandleContainer;
184
186 typedef std::list<VHierarchyNodeHandle> VHierarchyNodeHandleList;
187
188
189 //=============================================================================
190 } // namesapce VDPM
191 } // namespace OpenMesh
192 //=============================================================================
193 #endif // OPENMESH_VDPROGMESH_VHIERARCHYNODE_HH defined
194 //=============================================================================
OpenMesh::VDPM::VHierarchyNode::parent_handle
VHierarchyNodeHandle parent_handle()
Returns parent handle.
Definition: VHierarchyNode.hh:105
OpenMesh::VDPM::VHierarchyNodeHandleList
std::list< VHierarchyNodeHandle > VHierarchyNodeHandleList
Container for vertex hierarchy node handles.
Definition: VHierarchyNode.hh:186
OpenMesh::VectorT< float, 3 >
OpenMesh::VDPM::VHierarchyNodeIndex
Index of vertex hierarchy node.
Definition: VHierarchyNodeIndex.hh:73
OpenMesh::VDPM::VHierarchyNode::rchild_handle
VHierarchyNodeHandle rchild_handle()
Returns handle to right child.
Definition: VHierarchyNode.hh:111
OpenMesh::VDPM::VHierarchyNodeContainer
std::vector< VHierarchyNode > VHierarchyNodeContainer
Container for vertex hierarchy nodes.
Definition: VHierarchyNode.hh:180
OpenMesh::VertexHandle
Handle for a vertex entity.
Definition: Handles.hh:120
OpenMesh::VDPM::VHierarchyNode
Vertex hierarchy node.
Definition: VHierarchyNode.hh:90
OpenMesh::VDPM::VHierarchyNode::is_root
bool is_root() const
Returns true, if node is root else false.
Definition: VHierarchyNode.hh:97
OpenMesh::VDPM::VHierarchyNode::lchild_handle
VHierarchyNodeHandle lchild_handle()
Returns handle to left child.
Definition: VHierarchyNode.hh:108
OpenMesh::VDPM::VHierarchyNodeHandleContainer
std::vector< VHierarchyNodeHandle > VHierarchyNodeHandleContainer
Container for vertex hierarchy node handles.
Definition: VHierarchyNode.hh:183
OpenMesh::VDPM::VHierarchyNodeHandle
Handle for vertex hierarchy nodes.
Definition: VHierarchyNode.hh:77
OpenMesh::BaseHandle
Base class for all handle types.
Definition: Handles.hh:62
OpenMesh::VDPM::VHierarchyNode::is_leaf
bool is_leaf() const
Returns true, if node is leaf else false.
Definition: VHierarchyNode.hh:101
OpenMesh
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:59