OpenMesh

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

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
VHierarchyNode.hh
1 /*===========================================================================*\
2 * *
3 * OpenMesh *
4 * Copyright (C) 2001-2012 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: 736 $ *
38 * $Date: 2012-10-08 09:30:49 +0200 (Mo, 08 Okt 2012) $ *
39 * *
40 \*===========================================================================*/
41
42 //=============================================================================
43 //
44 // CLASS newClass
45 //
46 //=============================================================================
47
48 #ifndef OPENMESH_VDPROGMESH_VHIERARCHYNODE_HH
49 #define OPENMESH_VDPROGMESH_VHIERARCHYNODE_HH
50
51
52 //== INCLUDES =================================================================
53
54
55 #include <vector>
56 #include <list>
57 #include <OpenMesh/Core/Geometry/VectorT.hh>
58 #include <OpenMesh/Core/Mesh/Handles.hh>
59 #include <OpenMesh/Tools/VDPM/VHierarchyNodeIndex.hh>
60
61
62 //== FORWARDDECLARATIONS ======================================================
63
64
65 //== NAMESPACES ===============================================================
66
67 namespace OpenMesh {
68 namespace VDPM {
69
70 //== CLASS DEFINITION =========================================================
71
72
75 struct VHierarchyNodeHandle : public BaseHandle
76 {
77 explicit VHierarchyNodeHandle(int _idx=-1) : BaseHandle(_idx) {}
78 };
79
80
82 static const VHierarchyNodeHandle InvalidVHierarchyNodeHandle;
83
84
88 class VHierarchyNode
89 {
90 public:
91
92 VHierarchyNode() { }
93
95 bool is_root() const
96 { return (parent_handle_.is_valid() == false) ? true : false; }
97
99 bool is_leaf() const
100 { return (lchild_handle_.is_valid() == false) ? true : false; }
101
103 VHierarchyNodeHandle parent_handle() { return parent_handle_; }
104
106 VHierarchyNodeHandle lchild_handle() { return lchild_handle_; }
107
109 VHierarchyNodeHandle rchild_handle()
110 { return VHierarchyNodeHandle(lchild_handle_.idx()+1); }
111
112 void set_parent_handle(VHierarchyNodeHandle _parent_handle)
113 { parent_handle_ = _parent_handle; }
114
115 void set_children_handle(VHierarchyNodeHandle _lchild_handle)
116 { lchild_handle_ = _lchild_handle; }
117
118 VertexHandle vertex_handle() const { return vh_; }
119 float radius() const { return radius_; }
120 const OpenMesh::Vec3f& normal() const { return normal_; }
121 float sin_square() const { return sin_square_; }
122 float mue_square() const { return mue_square_; }
123 float sigma_square() const { return sigma_square_; }
124
125 void set_vertex_handle(OpenMesh::VertexHandle _vh) { vh_ = _vh; }
126 void set_radius(float _radius) { radius_ = _radius; }
127 void set_normal(const OpenMesh::Vec3f &_normal) { normal_ = _normal; }
128
129 void set_sin_square(float _sin_square) { sin_square_ = _sin_square; }
130 void set_mue_square(float _mue_square) { mue_square_ = _mue_square; }
131 void set_sigma_square(float _sigma_square) { sigma_square_ = _sigma_square; }
132
133 void set_semi_angle(float _semi_angle)
134 { float f=sinf(_semi_angle); sin_square_ = f*f; }
135
136 void set_mue(float _mue) { mue_square_ = _mue * _mue; }
137 void set_sigma(float _sigma) { sigma_square_ = _sigma * _sigma; }
138
139 const VHierarchyNodeIndex& node_index() const { return node_index_; }
140 const VHierarchyNodeIndex& fund_lcut_index() const
141 { return fund_cut_node_index_[0]; }
142
143 const VHierarchyNodeIndex& fund_rcut_index() const
144 { return fund_cut_node_index_[1]; }
145
146 VHierarchyNodeIndex& node_index()
147 { return node_index_; }
148
149 VHierarchyNodeIndex& fund_lcut_index() { return fund_cut_node_index_[0]; }
150 VHierarchyNodeIndex& fund_rcut_index() { return fund_cut_node_index_[1]; }
151
152 void set_index(const VHierarchyNodeIndex &_node_index)
153 { node_index_ = _node_index; }
154
155 void set_fund_lcut(const VHierarchyNodeIndex &_node_index)
156 { fund_cut_node_index_[0] = _node_index; }
157
158 void set_fund_rcut(const VHierarchyNodeIndex &_node_index)
159 { fund_cut_node_index_[1] = _node_index; }
160
161 private:
162 VertexHandle vh_;
163 float radius_;
164 Vec3f normal_;
165 float sin_square_;
166 float mue_square_;
167 float sigma_square_;
168
169 VHierarchyNodeHandle parent_handle_;
170 VHierarchyNodeHandle lchild_handle_;
171
172
173 VHierarchyNodeIndex node_index_;
174 VHierarchyNodeIndex fund_cut_node_index_[2];
175 };
176
178 typedef std::vector<VHierarchyNode> VHierarchyNodeContainer;
179
181 typedef std::vector<VHierarchyNodeHandle> VHierarchyNodeHandleContainer;
182
184 typedef std::list<VHierarchyNodeHandle> VHierarchyNodeHandleList;
185
186
187 //=============================================================================
188 } // namesapce VDPM
189 } // namespace OpenMesh
190 //=============================================================================
191 #endif // OPENMESH_VDPROGMESH_VHIERARCHYNODE_HH defined
192 //=============================================================================