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_VHIERARCHYNODEINDEX_HH
00033 #define OPENMESH_VDPROGMESH_VHIERARCHYNODEINDEX_HH
00034
00035
00036
00037 #include <vector>
00038 #include <assert.h>
00039
00040
00041
00042
00043
00044
00045 namespace OpenMesh {
00046 namespace VDPM {
00047
00048
00049
00050
00055 class VHierarchyNodeIndex
00056 {
00057 private:
00058 unsigned int value_;
00059
00060 public:
00061
00062 static const VHierarchyNodeIndex InvalidIndex;
00063
00064 public:
00065
00066 VHierarchyNodeIndex()
00067 { value_ = 0; }
00068
00069 VHierarchyNodeIndex(unsigned int _value)
00070 { value_ = _value; }
00071
00072 VHierarchyNodeIndex(const VHierarchyNodeIndex &_other)
00073 { value_ = _other.value_; }
00074
00075 VHierarchyNodeIndex(unsigned int _tree_id,
00076 unsigned int _node_id,
00077 unsigned short _tree_id_bits)
00078 {
00079 assert(_tree_id < ((unsigned int) 0x00000001 << _tree_id_bits));
00080 assert(_node_id < ((unsigned int) 0x00000001 << (32 - _tree_id_bits)));
00081 value_ = (_tree_id << (32 - _tree_id_bits)) | _node_id;
00082 }
00083
00084 bool is_valid(unsigned short _tree_id_bits) const
00085 { return node_id(_tree_id_bits) != 0 ? true : false; }
00086
00087 unsigned int tree_id(unsigned short _tree_id_bits) const
00088 { return value_ >> (32 - _tree_id_bits); }
00089
00090 unsigned int node_id(unsigned short _tree_id_bits) const
00091 { return value_ & ((unsigned int) 0xFFFFFFFF >> _tree_id_bits); }
00092
00093 bool operator< (const VHierarchyNodeIndex &other) const
00094 { return (value_ < other.value_) ? true : false; }
00095
00096 unsigned int value() const
00097 { return value_; }
00098 };
00099
00100
00102 typedef std::vector<VHierarchyNodeIndex> VHierarchyNodeIndexContainer;
00103
00104
00105
00106 }
00107 }
00108
00109 #endif // OPENMESH_VDPROGMESH_VHIERARCHYNODEINDEX_HH defined
00110