• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List
  • File Members

/home/hauberg/Dokumenter/Capture/humim-tracker-0.1/src/OpenTissue/OpenTissue/core/containers/t4mesh/t4mesh_t4node.h

Go to the documentation of this file.
00001 #ifndef OPENTISSUE_CORE_CONTAINERS_T4MESH_T4NODE_H
00002 #define OPENTISSUE_CORE_CONTAINERS_T4MESH_T4NODE_H
00003 //
00004 // OpenTissue Template Library
00005 // - A generic toolbox for physics-based modeling and simulation.
00006 // Copyright (C) 2008 Department of Computer Science, University of Copenhagen.
00007 //
00008 // OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php
00009 //
00010 #include <OpenTissue/configuration.h>
00011 
00012 #include <list>
00013 #include <cassert>
00014 
00015 namespace OpenTissue
00016 {
00017   namespace t4mesh
00018   {
00019 
00020     template< typename mesh_type_>
00021     class T4Node : public mesh_type_::node_traits
00022     {
00023     public:
00024 
00025       typedef          mesh_type_                            mesh_type;
00026       typedef typename mesh_type::node_type                  node_type;
00027       typedef typename mesh_type::tetrahedron_type           tetrahedron_type;
00028       typedef typename mesh_type::index_type                 index_type;
00029       typedef          std::list<index_type>                 tetrahedra_index_container;
00030       typedef typename tetrahedra_index_container::iterator  tetrahedra_idx_iterator;
00031 
00032     protected:
00033 
00034       index_type                   m_idx;              
00035       mesh_type                  * m_owner;            
00036       tetrahedra_index_container   m_tetrahedra;       
00037 
00038     private:
00039 
00040       friend class t4mesh_core_access;
00041 
00042       void set_index(index_type idx)            { m_idx = idx;                 }
00043       void set_owner(mesh_type * owner)       { m_owner = owner;             }
00044       void tetrahedra_push_back(index_type idx) { m_tetrahedra.push_back(idx); }
00045       void tetrahedra_remove(index_type idx)    { m_tetrahedra.remove(idx);    }
00046 
00047     public:
00048 
00049       class tetrahedron_circulator
00050       {
00051       private:
00052 
00053         node_type               * m_node;    
00054         tetrahedra_idx_iterator   m_it;      
00055 
00056       public:
00057 
00058         tetrahedron_circulator() 
00059           : m_node( 0 )
00060           , m_it( 0 ) 
00061         {}
00062 
00063         tetrahedron_circulator( node_type * node, tetrahedra_idx_iterator pos) 
00064           : m_node( node )
00065           , m_it( pos )
00066         {
00067           assert(m_node || !"tetrahedron_circulator() : node was null");
00068           assert(m_node->m_owner || !"tetrahedron_circulator(..) : owner was null");
00069         }
00070 
00071         bool operator== ( tetrahedron_circulator const & other ) const   
00072         {   
00073           return ( m_node == other.m_node && m_it == other.m_it );  
00074         }
00075 
00076         bool operator!= ( tetrahedron_circulator const & other ) const   
00077         {
00078           return !( *this == other);   
00079         }
00080 
00081         tetrahedron_type & operator*()
00082         {
00083           assert(m_node || !"tetrahedron_circulator::* : node was null");
00084           assert(m_node->m_owner || !"tetrahedron_circulator::* : owner was null");
00085           return *(m_node->m_owner->tetrahedron(*m_it));
00086         }
00087 
00088         tetrahedron_type * operator->()
00089         {
00090           assert(m_node || !"tetrahedron_circulator::-> : node was null");
00091           assert(m_node->m_owner || !"tetrahedron_circulator::-> : owner was null");
00092           return &(*(m_node->m_owner->tetrahedron(*m_it)));
00093         }
00094 
00095         tetrahedron_circulator & operator++()
00096         {
00097           assert(m_node || !"tetrahedron_circulator::++ : node was null");
00098           assert(m_node->m_owner || !"tetrahedron_circulator::++ : owner was null");
00099           ++m_it; 
00100           return *this;
00101         }
00102 
00103       };
00104 
00105       tetrahedron_circulator begin() { return tetrahedron_circulator( this, m_tetrahedra.begin() ); }
00106       tetrahedron_circulator end()   { return tetrahedron_circulator( this, m_tetrahedra.end() );   }
00107 
00114       size_t size_tetrahedra() const { return m_tetrahedra.size(); }
00115 
00116       bool isolated() const { return m_tetrahedra.empty(); }
00117 
00118     public:
00119 
00120       T4Node() 
00121         : m_idx( mesh_type::undefined() )
00122         , m_owner(0)
00123         , m_tetrahedra() 
00124       {}
00125 
00126     public:
00127 
00128       index_type        idx()   const { return m_idx;   }
00129       mesh_type       * owner()       { return m_owner; }
00130       mesh_type const * owner() const { return m_owner; }
00131 
00132     };
00133 
00134   } // namespace t4mesh
00135 } // namespace OpenTissue
00136 
00137 //OPENTISSUE_CORE_CONTAINERS_T4MESH_T4NODE_H
00138 #endif

Generated on Thu Dec 1 2011 12:51:24 for HUMIM Tracker by  doxygen 1.7.1