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 #ifndef OPENMESH_VDPROGMESH_VHIERARCHYNODE_HH
00033 #define OPENMESH_VDPROGMESH_VHIERARCHYNODE_HH
00034
00035
00036
00037
00038
00039 #include <vector>
00040 #include <list>
00041 #include <OpenMesh/Core/Math/VectorT.hh>
00042 #include <OpenMesh/Core/Mesh/Kernels/Common/Handles.hh>
00043 #include <OpenMesh/Tools/VDPM/VHierarchyNodeIndex.hh>
00044
00045
00046
00047
00048
00049
00050
00051 namespace OpenMesh {
00052 namespace VDPM {
00053
00054
00055
00056
00059 struct VHierarchyNodeHandle : public BaseHandle
00060 {
00061 explicit VHierarchyNodeHandle(int _idx=-1) : BaseHandle(_idx) {}
00062 };
00063
00064
00066 static const VHierarchyNodeHandle InvalidVHierarchyNodeHandle;
00067
00068
00072 class VHierarchyNode
00073 {
00074 public:
00075
00076 VHierarchyNode() { }
00077
00079 bool is_root() const
00080 { return (parent_handle_.is_valid() == false) ? true : false; }
00081
00083 bool is_leaf() const
00084 { return (lchild_handle_.is_valid() == false) ? true : false; }
00085
00087 VHierarchyNodeHandle parent_handle() { return parent_handle_; }
00088
00090 VHierarchyNodeHandle lchild_handle() { return lchild_handle_; }
00091
00093 VHierarchyNodeHandle rchild_handle()
00094 { return VHierarchyNodeHandle(lchild_handle_.idx()+1); }
00095
00096 void set_parent_handle(VHierarchyNodeHandle _parent_handle)
00097 { parent_handle_ = _parent_handle; }
00098
00099 void set_children_handle(VHierarchyNodeHandle _lchild_handle)
00100 { lchild_handle_ = _lchild_handle; }
00101
00102 VertexHandle vertex_handle() const { return vh_; }
00103 float radius() const { return radius_; }
00104 const OpenMesh::Vec3f& normal() const { return normal_; }
00105 float sin_square() const { return sin_square_; }
00106 float mue_square() const { return mue_square_; }
00107 float sigma_square() const { return sigma_square_; }
00108
00109 void set_vertex_handle(OpenMesh::VertexHandle _vh) { vh_ = _vh; }
00110 void set_radius(float _radius) { radius_ = _radius; }
00111 void set_normal(const OpenMesh::Vec3f &_normal) { normal_ = _normal; }
00112
00113 void set_sin_square(float _sin_square) { sin_square_ = _sin_square; }
00114 void set_mue_square(float _mue_square) { mue_square_ = _mue_square; }
00115 void set_sigma_square(float _sigma_square) { sigma_square_ = _sigma_square; }
00116
00117 void set_semi_angle(float _semi_angle)
00118 { float f=sinf(_semi_angle); sin_square_ = f*f; }
00119
00120 void set_mue(float _mue) { mue_square_ = _mue * _mue; }
00121 void set_sigma(float _sigma) { sigma_square_ = _sigma * _sigma; }
00122
00123 const VHierarchyNodeIndex& node_index() const { return node_index_; }
00124 const VHierarchyNodeIndex& fund_lcut_index() const
00125 { return fund_cut_node_index_[0]; }
00126
00127 const VHierarchyNodeIndex& fund_rcut_index() const
00128 { return fund_cut_node_index_[1]; }
00129
00130 VHierarchyNodeIndex& node_index()
00131 { return node_index_; }
00132
00133 VHierarchyNodeIndex& fund_lcut_index() { return fund_cut_node_index_[0]; }
00134 VHierarchyNodeIndex& fund_rcut_index() { return fund_cut_node_index_[1]; }
00135
00136 void set_index(const VHierarchyNodeIndex &_node_index)
00137 { node_index_ = _node_index; }
00138
00139 void set_fund_lcut(const VHierarchyNodeIndex &_node_index)
00140 { fund_cut_node_index_[0] = _node_index; }
00141
00142 void set_fund_rcut(const VHierarchyNodeIndex &_node_index)
00143 { fund_cut_node_index_[1] = _node_index; }
00144
00145 private:
00146 VertexHandle vh_;
00147 float radius_;
00148 Vec3f normal_;
00149 float sin_square_;
00150 float mue_square_;
00151 float sigma_square_;
00152
00153 VHierarchyNodeHandle parent_handle_;
00154 VHierarchyNodeHandle lchild_handle_;
00155
00156
00157 VHierarchyNodeIndex node_index_;
00158 VHierarchyNodeIndex fund_cut_node_index_[2];
00159 };
00160
00162 typedef std::vector<VHierarchyNode> VHierarchyNodeContainer;
00163
00165 typedef std::vector<VHierarchyNodeHandle> VHierarchyNodeHandleContainer;
00166
00168 typedef std::list<VHierarchyNodeHandle> VHierarchyNodeHandleList;
00169
00170
00171
00172 }
00173 }
00174
00175 #endif // OPENMESH_VDPROGMESH_VHIERARCHYNODE_HH defined
00176