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

VHierarchy.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_VHIERARCHY_HH
00033 #define OPENMESH_VDPROGMESH_VHIERARCHY_HH
00034 
00035 
00036 //== INCLUDES =================================================================
00037 
00038 #include <vector>
00039 #include <OpenMesh/Tools/VDPM/VHierarchyNode.hh>
00040 
00041 
00042 //== FORWARDDECLARATIONS ======================================================
00043 
00044 
00045 //== NAMESPACES ===============================================================
00046 
00047 namespace OpenMesh {
00048 namespace VDPM {
00049 
00050 //== CLASS DEFINITION =========================================================
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_; // node_id_bits_ = 32-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 } // namespace VDPM
00167 } // namespace OpenMesh
00168 //=============================================================================
00169 #endif // OPENMESH_VDPROGMESH_VHIERARCHY_HH defined
00170 //=============================================================================

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