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_VHIERARCHY_HH
00033 #define OPENMESH_VDPROGMESH_VHIERARCHY_HH
00034
00035
00036
00037
00038 #include <vector>
00039 #include <OpenMesh/Tools/VDPM/VHierarchyNode.hh>
00040
00041
00042
00043
00044
00045
00046
00047 namespace OpenMesh {
00048 namespace VDPM {
00049
00050
00051
00052
00055 class VHierarchy
00056 {
00057 public:
00058
00059 typedef unsigned int id_t;
00060
00061 private:
00062
00063 VHierarchyNodeContainer nodes_;
00064 unsigned int n_roots_;
00065 unsigned char tree_id_bits_;
00066
00067 public:
00068
00069 VHierarchy();
00070
00071 void clear() { nodes_.clear(); n_roots_ = 0; }
00072 unsigned char tree_id_bits() const { return tree_id_bits_; }
00073 unsigned int num_roots() const { return n_roots_; }
00074 unsigned int num_nodes() const { return nodes_.size(); }
00075
00076 VHierarchyNodeIndex generate_node_index(id_t _tree_id, id_t _node_id)
00077 {
00078 return VHierarchyNodeIndex(_tree_id, _node_id, tree_id_bits_);
00079 }
00080
00081
00082 void set_num_roots(unsigned int _n_roots);
00083
00084 VHierarchyNodeHandle root_handle(unsigned int i) const
00085 {
00086 return VHierarchyNodeHandle( (int)i );
00087 }
00088
00089
00090 const VHierarchyNode& node(VHierarchyNodeHandle _vhierarchynode_handle) const
00091 {
00092 return nodes_[_vhierarchynode_handle.idx()];
00093 }
00094
00095
00096 VHierarchyNode& node(VHierarchyNodeHandle _vhierarchynode_handle)
00097 {
00098 return nodes_[_vhierarchynode_handle.idx()];
00099 }
00100
00101 VHierarchyNodeHandle add_node();
00102 VHierarchyNodeHandle add_node(const VHierarchyNode &_node);
00103
00104 void make_children(VHierarchyNodeHandle &_parent_handle);
00105
00106 bool is_ancestor(VHierarchyNodeIndex _ancestor_index,
00107 VHierarchyNodeIndex _descendent_index);
00108
00109 bool is_leaf_node(VHierarchyNodeHandle _node_handle)
00110 { return nodes_[_node_handle.idx()].is_leaf(); }
00111
00112 bool is_root_node(VHierarchyNodeHandle _node_handle)
00113 { return nodes_[_node_handle.idx()].is_root(); }
00114
00115
00116 const OpenMesh::Vec3f& normal(VHierarchyNodeHandle _node_handle) const
00117 {
00118 return nodes_[_node_handle.idx()].normal();
00119 }
00120
00121 const VHierarchyNodeIndex&
00122 node_index(VHierarchyNodeHandle _node_handle) const
00123 { return nodes_[_node_handle.idx()].node_index(); }
00124
00125 VHierarchyNodeIndex& node_index(VHierarchyNodeHandle _node_handle)
00126 { return nodes_[_node_handle.idx()].node_index(); }
00127
00128 const VHierarchyNodeIndex&
00129 fund_lcut_index(VHierarchyNodeHandle _node_handle) const
00130 { return nodes_[_node_handle.idx()].fund_lcut_index(); }
00131
00132 VHierarchyNodeIndex& fund_lcut_index(VHierarchyNodeHandle _node_handle)
00133 { return nodes_[_node_handle.idx()].fund_lcut_index(); }
00134
00135 const VHierarchyNodeIndex&
00136 fund_rcut_index(VHierarchyNodeHandle _node_handle) const
00137 { return nodes_[_node_handle.idx()].fund_rcut_index(); }
00138
00139 VHierarchyNodeIndex& fund_rcut_index(VHierarchyNodeHandle _node_handle)
00140 { return nodes_[_node_handle.idx()].fund_rcut_index(); }
00141
00142 VertexHandle vertex_handle(VHierarchyNodeHandle _node_handle)
00143 { return nodes_[_node_handle.idx()].vertex_handle(); }
00144
00145 VHierarchyNodeHandle parent_handle(VHierarchyNodeHandle _node_handle)
00146 { return nodes_[_node_handle.idx()].parent_handle(); }
00147
00148 VHierarchyNodeHandle lchild_handle(VHierarchyNodeHandle _node_handle)
00149 { return nodes_[_node_handle.idx()].lchild_handle(); }
00150
00151 VHierarchyNodeHandle rchild_handle(VHierarchyNodeHandle _node_handle)
00152 { return nodes_[_node_handle.idx()].rchild_handle(); }
00153
00154 VHierarchyNodeHandle node_handle(VHierarchyNodeIndex _node_index);
00155
00156 private:
00157
00158 VHierarchyNodeHandle compute_dependency(VHierarchyNodeIndex index0,
00159 VHierarchyNodeIndex index1);
00160
00161 };
00162
00163
00164
00165
00166 }
00167 }
00168
00169 #endif // OPENMESH_VDPROGMESH_VHIERARCHY_HH defined
00170