OpenMesh
OpenMesh/Tools/VDPM/VHierarchyNode.hh
00001 /*===========================================================================*\
00002  *                                                                           *
00003  *                               OpenMesh                                    *
00004  *      Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen      *
00005  *                           www.openmesh.org                                *
00006  *                                                                           *
00007  *---------------------------------------------------------------------------* 
00008  *  This file is part of OpenMesh.                                           *
00009  *                                                                           *
00010  *  OpenMesh is free software: you can redistribute it and/or modify         * 
00011  *  it under the terms of the GNU Lesser General Public License as           *
00012  *  published by the Free Software Foundation, either version 3 of           *
00013  *  the License, or (at your option) any later version with the              *
00014  *  following exceptions:                                                    *
00015  *                                                                           *
00016  *  If other files instantiate templates or use macros                       *
00017  *  or inline functions from this file, or you compile this file and         *
00018  *  link it with other files to produce an executable, this file does        *
00019  *  not by itself cause the resulting executable to be covered by the        *
00020  *  GNU Lesser General Public License. This exception does not however       *
00021  *  invalidate any other reasons why the executable file might be            *
00022  *  covered by the GNU Lesser General Public License.                        *
00023  *                                                                           *
00024  *  OpenMesh is distributed in the hope that it will be useful,              *
00025  *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
00026  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
00027  *  GNU Lesser General Public License for more details.                      *
00028  *                                                                           *
00029  *  You should have received a copy of the GNU LesserGeneral Public          *
00030  *  License along with OpenMesh.  If not,                                    *
00031  *  see <http://www.gnu.org/licenses/>.                                      *
00032  *                                                                           *
00033 \*===========================================================================*/ 
00034 
00035 /*===========================================================================*\
00036  *                                                                           *             
00037  *   $Revision: 362 $                                                         *
00038  *   $Date: 2011-01-26 10:21:12 +0100 (Mi, 26 Jan 2011) $                   *
00039  *                                                                           *
00040 \*===========================================================================*/
00041 
00042 //=============================================================================
00043 //
00044 //  CLASS newClass
00045 //
00046 //=============================================================================
00047 
00048 #ifndef OPENMESH_VDPROGMESH_VHIERARCHYNODE_HH
00049 #define OPENMESH_VDPROGMESH_VHIERARCHYNODE_HH
00050 
00051 
00052 //== INCLUDES =================================================================
00053 
00054 
00055 #include <vector>
00056 #include <list>
00057 #include <OpenMesh/Core/Geometry/VectorT.hh>
00058 #include <OpenMesh/Core/Mesh/Handles.hh>
00059 #include <OpenMesh/Tools/VDPM/VHierarchyNodeIndex.hh>
00060 
00061 
00062 //== FORWARDDECLARATIONS ======================================================
00063 
00064 
00065 //== NAMESPACES ===============================================================
00066 
00067 namespace OpenMesh {
00068 namespace VDPM {
00069 
00070 //== CLASS DEFINITION =========================================================
00071 
00072               
00075 struct VHierarchyNodeHandle : public BaseHandle
00076 {
00077   explicit VHierarchyNodeHandle(int _idx=-1) : BaseHandle(_idx) {}
00078 };
00079 
00080 
00082 static const VHierarchyNodeHandle InvalidVHierarchyNodeHandle;
00083 
00084 
00088 class VHierarchyNode
00089 {
00090 public:
00091 
00092   VHierarchyNode() { }
00093 
00095   bool is_root() const
00096   { return (parent_handle_.is_valid() == false) ? true : false; }
00097 
00099   bool is_leaf() const
00100   { return (lchild_handle_.is_valid() == false) ? true : false; }
00101   
00103   VHierarchyNodeHandle parent_handle() { return parent_handle_; }
00104   
00106   VHierarchyNodeHandle lchild_handle() { return lchild_handle_; }
00107 
00109   VHierarchyNodeHandle rchild_handle() 
00110   { return VHierarchyNodeHandle(lchild_handle_.idx()+1); }
00111 
00112   void set_parent_handle(VHierarchyNodeHandle _parent_handle)
00113   { parent_handle_ = _parent_handle; }
00114 
00115   void set_children_handle(VHierarchyNodeHandle _lchild_handle)
00116   { lchild_handle_ = _lchild_handle; }
00117 
00118   VertexHandle vertex_handle() const                  { return vh_; }
00119   float radius() const                                { return radius_; }
00120   const OpenMesh::Vec3f& normal() const               { return normal_; }
00121   float sin_square() const                            { return sin_square_; }
00122   float mue_square() const                            { return mue_square_; }
00123   float sigma_square() const                          { return sigma_square_; }
00124 
00125   void set_vertex_handle(OpenMesh::VertexHandle _vh)  { vh_     = _vh; }
00126   void set_radius(float _radius)                      { radius_ = _radius; }
00127   void set_normal(const OpenMesh::Vec3f &_normal)     { normal_ = _normal; }
00128   
00129   void set_sin_square(float _sin_square)      { sin_square_ = _sin_square; }
00130   void set_mue_square(float _mue_square)      { mue_square_ = _mue_square; }
00131   void set_sigma_square(float _sigma_square)  { sigma_square_ = _sigma_square; }
00132   
00133   void set_semi_angle(float _semi_angle) 
00134   { float f=sinf(_semi_angle); sin_square_ = f*f; }
00135 
00136   void set_mue(float _mue)                        { mue_square_ = _mue * _mue; }
00137   void set_sigma(float _sigma)              { sigma_square_ = _sigma * _sigma; }
00138 
00139   const VHierarchyNodeIndex& node_index() const         { return  node_index_; }
00140   const VHierarchyNodeIndex& fund_lcut_index() const 
00141   { return  fund_cut_node_index_[0]; }
00142 
00143   const VHierarchyNodeIndex& fund_rcut_index() const
00144   { return  fund_cut_node_index_[1]; }
00145 
00146   VHierarchyNodeIndex& node_index()
00147   { return  node_index_; }
00148 
00149   VHierarchyNodeIndex& fund_lcut_index()   { return  fund_cut_node_index_[0]; }
00150   VHierarchyNodeIndex& fund_rcut_index()   { return  fund_cut_node_index_[1]; }
00151 
00152   void set_index(const VHierarchyNodeIndex &_node_index)
00153   { node_index_ = _node_index; }
00154 
00155   void set_fund_lcut(const VHierarchyNodeIndex &_node_index)
00156   { fund_cut_node_index_[0] = _node_index; }
00157 
00158   void set_fund_rcut(const VHierarchyNodeIndex &_node_index)
00159   { fund_cut_node_index_[1] = _node_index; }
00160 
00161 private:
00162   VertexHandle            vh_;
00163   float                   radius_;
00164   Vec3f                   normal_;
00165   float                   sin_square_;
00166   float                   mue_square_;
00167   float                   sigma_square_;
00168 
00169   VHierarchyNodeHandle    parent_handle_;
00170   VHierarchyNodeHandle    lchild_handle_;
00171 
00172 
00173   VHierarchyNodeIndex     node_index_;
00174   VHierarchyNodeIndex     fund_cut_node_index_[2];
00175 };
00176 
00178 typedef std::vector<VHierarchyNode>         VHierarchyNodeContainer;
00179 
00181 typedef std::vector<VHierarchyNodeHandle>   VHierarchyNodeHandleContainer;
00182 
00184 typedef std::list<VHierarchyNodeHandle>     VHierarchyNodeHandleList;
00185 
00186 
00187 //=============================================================================
00188 } // namesapce VDPM
00189 } // namespace OpenMesh
00190 //=============================================================================
00191 #endif //  OPENMESH_VDPROGMESH_VHIERARCHYNODE_HH defined
00192 //=============================================================================