Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

VHierarchyNodeIndex.hh

00001 /*===========================================================================*\
00002  *                                                                           *
00003  *                               OpenMesh                                    *
00004  *      Copyright (C) 2001-2005 by Computer Graphics Group, RWTH Aachen      *
00005  *                           www.openmesh.org                                *
00006  *                                                                           *
00007  *---------------------------------------------------------------------------* 
00008  *                                                                           *
00009  *                                License                                    *
00010  *                                                                           *
00011  *  This library is free software; you can redistribute it and/or modify it  *
00012  *  under the terms of the GNU Library General Public License as published   *
00013  *  by the Free Software Foundation, version 2.                              *
00014  *                                                                           *
00015  *  This library is distributed in the hope that it will be useful, but      *
00016  *  WITHOUT ANY WARRANTY; without even the implied warranty of               *
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU        *
00018  *  Library General Public License for more details.                         *
00019  *                                                                           *
00020  *  You should have received a copy of the GNU Library General Public        *
00021  *  License along with this library; if not, write to the Free Software      *
00022  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                *
00023  *                                                                           *
00024 \*===========================================================================*/
00025 
00026 //=============================================================================
00027 //
00028 //  CLASS newClass
00029 //
00030 //=============================================================================
00031 
00032 #ifndef OPENMESH_VDPROGMESH_VHIERARCHYNODEINDEX_HH
00033 #define OPENMESH_VDPROGMESH_VHIERARCHYNODEINDEX_HH
00034 
00035 //== INCLUDES =================================================================
00036 
00037 #include <vector>
00038 #include <assert.h>
00039 
00040 //== FORWARDDECLARATIONS ======================================================
00041 
00042 
00043 //== NAMESPACES ===============================================================
00044 
00045 namespace OpenMesh {
00046 namespace VDPM {
00047 
00048 //== CLASS DEFINITION =========================================================
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 } // namespace VDPM
00107 } // namespace OpenMesh
00108 //=============================================================================
00109 #endif //  OPENMESH_VDPROGMESH_VHIERARCHYNODEINDEX_HH defined
00110 //=============================================================================

acg pic Project OpenMesh, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .