00001 #ifndef OPENTISSUE_CORE_CONTAINERS_MESH_POLYMESH_POLYMESH_HAFLEDGE_H 00002 #define OPENTISSUE_CORE_CONTAINERS_MESH_POLYMESH_POLYMESH_HAFLEDGE_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 namespace OpenTissue 00013 { 00014 namespace polymesh 00015 { 00016 00017 template<typename polymesh_type_ > 00018 class PolyMeshHalfEdge : public polymesh_type_::halfedge_traits 00019 { 00020 public: 00021 00022 typedef polymesh_type_ mesh_type; 00023 00024 typedef typename mesh_type::vertex_handle vertex_handle; 00025 typedef typename mesh_type::halfedge_handle halfedge_handle; 00026 typedef typename mesh_type::edge_handle edge_handle; 00027 typedef typename mesh_type::face_handle face_handle; 00028 00029 typedef typename mesh_type::vertex_iterator vertex_iterator; 00030 typedef typename mesh_type::halfedge_iterator halfedge_iterator; 00031 typedef typename mesh_type::edge_iterator edge_iterator; 00032 typedef typename mesh_type::face_iterator face_iterator; 00033 00034 private: 00035 00036 halfedge_handle m_self; 00037 mesh_type * m_owner; 00038 halfedge_handle m_next; 00039 halfedge_handle m_prev; 00040 face_handle m_face; 00041 halfedge_handle m_twin; 00042 vertex_handle m_destination; 00043 edge_handle m_edge; 00044 00045 public: 00046 00047 PolyMeshHalfEdge() 00048 : m_self() 00049 , m_owner(0) 00050 , m_next() 00051 , m_prev() 00052 , m_face() 00053 , m_twin() 00054 , m_destination() 00055 , m_edge() 00056 {} 00057 00058 public: 00059 00060 halfedge_handle get_handle() const { return m_self; } 00061 mesh_type * get_owner() const { return m_owner; } 00062 00063 halfedge_handle get_next_handle() const { return m_next; } 00064 halfedge_iterator get_next_iterator() const { return m_owner->get_halfedge_iterator(m_next); } 00065 00066 halfedge_handle get_twin_handle() const { return m_twin; } 00067 halfedge_iterator get_twin_iterator() const { return m_owner->get_halfedge_iterator(m_twin); } 00068 00069 vertex_handle get_origin_handle() const { return get_twin_iterator()->get_destination_handle(); } 00070 vertex_iterator get_origin_iterator() const { return get_twin_iterator()->get_destination_iterator(); } 00071 00072 vertex_handle get_destination_handle() const { return m_destination; } 00073 vertex_iterator get_destination_iterator() const { return m_owner->get_vertex_iterator(m_destination); } 00074 00075 face_handle get_face_handle() const { return m_face; } 00076 face_iterator get_face_iterator() const { return m_owner->get_face_iterator(m_face); } 00077 00078 halfedge_handle get_prev_handle() const { return m_prev; } 00079 halfedge_iterator get_prev_iterator() const { return m_owner->get_halfedge_iterator(m_prev); } 00080 00081 edge_handle get_edge_handle() const { return m_edge; } 00082 edge_iterator get_edge_iterator() const { return m_owner->get_edge_iterator(m_edge); } 00083 00084 private: 00085 00086 friend class polymesh_core_access; 00087 void set_handle(halfedge_handle h) { m_self = h; } 00088 void set_owner(mesh_type * owner){ m_owner = owner; } 00089 void set_next_handle(halfedge_handle h) 00090 { 00091 //if(m_owner->is_valid_halfedge_handle(m_next)) 00092 //{ 00093 // m_owner->get_halfedge_iterator(m_next)->m_prev = m_owner->null_halfedge_handle; 00094 //} 00095 00096 m_next = h; 00097 00098 if(m_owner->is_valid_halfedge_handle(h)) 00099 { 00100 m_owner->get_halfedge_iterator(h)->m_prev = m_self; 00101 } 00102 } 00103 void set_face_handle(face_handle f){ m_face = f; } 00104 void set_twin_handle(halfedge_handle h){ m_twin = h; } 00105 void set_destination_handle(vertex_handle v){ m_destination = v; } 00106 void set_edge_handle(edge_handle e){ m_edge = e; } 00107 00108 }; 00109 00110 } // namespace polymesh 00111 } // namespace OpenTissue 00112 00113 //OPENTISSUE_CORE_CONTAINERS_MESH_POLYMESH_POLYMESH_HAFLEDGE_H 00114 #endif