00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #ifndef OPENMESH_VDPROGMESH_VHIERARCHYNODE_HH
00049 #define OPENMESH_VDPROGMESH_VHIERARCHYNODE_HH
00050
00051
00052
00053
00054
00055 #include <vector>
00056 #include <list>
00057 #include <OpenMesh/Core/Geometry/VectorT.hh>
00058 #include <OpenMesh/Core/Mesh/Handles.hh>
00059 #include <OpenMesh/Tools/VDPM/VHierarchyNodeIndex.hh>
00060
00061
00062
00063
00064
00065
00066
00067 namespace OpenMesh {
00068 namespace VDPM {
00069
00070
00071
00072
00075 struct VHierarchyNodeHandle : public BaseHandle
00076 {
00077 explicit VHierarchyNodeHandle(int _idx=-1) : BaseHandle(_idx) {}
00078 };
00079
00080
00082 static const VHierarchyNodeHandle InvalidVHierarchyNodeHandle;
00083
00084
00088 class VHierarchyNode
00089 {
00090 public:
00091
00092 VHierarchyNode() { }
00093
00095 bool is_root() const
00096 { return (parent_handle_.is_valid() == false) ? true : false; }
00097
00099 bool is_leaf() const
00100 { return (lchild_handle_.is_valid() == false) ? true : false; }
00101
00103 VHierarchyNodeHandle parent_handle() { return parent_handle_; }
00104
00106 VHierarchyNodeHandle lchild_handle() { return lchild_handle_; }
00107
00109 VHierarchyNodeHandle rchild_handle()
00110 { return VHierarchyNodeHandle(lchild_handle_.idx()+1); }
00111
00112 void set_parent_handle(VHierarchyNodeHandle _parent_handle)
00113 { parent_handle_ = _parent_handle; }
00114
00115 void set_children_handle(VHierarchyNodeHandle _lchild_handle)
00116 { lchild_handle_ = _lchild_handle; }
00117
00118 VertexHandle vertex_handle() const { return vh_; }
00119 float radius() const { return radius_; }
00120 const OpenMesh::Vec3f& normal() const { return normal_; }
00121 float sin_square() const { return sin_square_; }
00122 float mue_square() const { return mue_square_; }
00123 float sigma_square() const { return sigma_square_; }
00124
00125 void set_vertex_handle(OpenMesh::VertexHandle _vh) { vh_ = _vh; }
00126 void set_radius(float _radius) { radius_ = _radius; }
00127 void set_normal(const OpenMesh::Vec3f &_normal) { normal_ = _normal; }
00128
00129 void set_sin_square(float _sin_square) { sin_square_ = _sin_square; }
00130 void set_mue_square(float _mue_square) { mue_square_ = _mue_square; }
00131 void set_sigma_square(float _sigma_square) { sigma_square_ = _sigma_square; }
00132
00133 void set_semi_angle(float _semi_angle)
00134 { float f=sinf(_semi_angle); sin_square_ = f*f; }
00135
00136 void set_mue(float _mue) { mue_square_ = _mue * _mue; }
00137 void set_sigma(float _sigma) { sigma_square_ = _sigma * _sigma; }
00138
00139 const VHierarchyNodeIndex& node_index() const { return node_index_; }
00140 const VHierarchyNodeIndex& fund_lcut_index() const
00141 { return fund_cut_node_index_[0]; }
00142
00143 const VHierarchyNodeIndex& fund_rcut_index() const
00144 { return fund_cut_node_index_[1]; }
00145
00146 VHierarchyNodeIndex& node_index()
00147 { return node_index_; }
00148
00149 VHierarchyNodeIndex& fund_lcut_index() { return fund_cut_node_index_[0]; }
00150 VHierarchyNodeIndex& fund_rcut_index() { return fund_cut_node_index_[1]; }
00151
00152 void set_index(const VHierarchyNodeIndex &_node_index)
00153 { node_index_ = _node_index; }
00154
00155 void set_fund_lcut(const VHierarchyNodeIndex &_node_index)
00156 { fund_cut_node_index_[0] = _node_index; }
00157
00158 void set_fund_rcut(const VHierarchyNodeIndex &_node_index)
00159 { fund_cut_node_index_[1] = _node_index; }
00160
00161 private:
00162 VertexHandle vh_;
00163 float radius_;
00164 Vec3f normal_;
00165 float sin_square_;
00166 float mue_square_;
00167 float sigma_square_;
00168
00169 VHierarchyNodeHandle parent_handle_;
00170 VHierarchyNodeHandle lchild_handle_;
00171
00172
00173 VHierarchyNodeIndex node_index_;
00174 VHierarchyNodeIndex fund_cut_node_index_[2];
00175 };
00176
00178 typedef std::vector<VHierarchyNode> VHierarchyNodeContainer;
00179
00181 typedef std::vector<VHierarchyNodeHandle> VHierarchyNodeHandleContainer;
00182
00184 typedef std::list<VHierarchyNodeHandle> VHierarchyNodeHandleList;
00185
00186
00187
00188 }
00189 }
00190
00191 #endif // OPENMESH_VDPROGMESH_VHIERARCHYNODE_HH defined
00192