00001 #ifndef OPENTISSUE_CORE_CONTAINERS_MESH_POLYMESH_UTIL_POLYMESH_IS_BOUNDARY_H 00002 #define OPENTISSUE_CORE_CONTAINERS_MESH_POLYMESH_UTIL_POLYMESH_IS_BOUNDARY_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 <OpenTissue/core/containers/mesh/polymesh/polymesh_halfedge.h> 00013 #include <OpenTissue/core/containers/mesh/polymesh/polymesh_edge.h> 00014 #include <OpenTissue/core/containers/mesh/polymesh/polymesh_vertex.h> 00015 #include <OpenTissue/core/containers/mesh/polymesh/polymesh_face.h> 00016 00017 namespace OpenTissue 00018 { 00019 namespace polymesh 00020 { 00021 00022 template<typename mesh_type> 00023 bool is_boundary(PolyMeshHalfEdge<mesh_type> const & h) 00024 { 00025 if(h.get_face_handle().is_null()) 00026 return true; 00027 return false; 00028 } 00029 00030 template<typename mesh_type> 00031 bool is_boundary(PolyMeshVertex<mesh_type> const & v) 00032 { 00033 typedef typename mesh_type::vertex_halfedge_circulator vertex_halfedge_circulator; 00034 00035 vertex_halfedge_circulator h(v), end; 00036 bool got_edges = false; 00037 for(;h!=end;++h) 00038 { 00039 got_edges = true; 00040 if( is_boundary( *h ) ) 00041 return true; 00042 } 00043 if(got_edges) 00044 return false; 00045 return true; 00046 } 00047 00048 template<typename mesh_type> 00049 bool is_boundary(PolyMeshEdge<mesh_type> const & e) 00050 { 00051 typedef typename mesh_type::halfedge_iterator halfedge_iterator; 00052 00053 halfedge_iterator h0 = e.get_halfedge0_iterator(); 00054 if( is_boundary( *h0 ) ) 00055 return true; 00056 halfedge_iterator h1 = e.get_halfedge1_iterator(); 00057 if( is_boundary( *h1 ) ) 00058 return true; 00059 return false; 00060 } 00061 00062 template<typename mesh_type> 00063 bool is_boundary(PolyMeshFace<mesh_type> const & f) 00064 { 00065 typedef typename mesh_type::face_halfedge_circulator face_halfedge_circulator; 00066 00067 face_halfedge_circulator h(f),end; 00068 for( ; h!=end; ++h) 00069 { 00070 if( is_boundary( *(h->get_twin_iterator()) ) ) 00071 return true; 00072 } 00073 return false; 00074 } 00075 00076 } // namespace polymesh 00077 } // namespace OpenTissue 00078 00079 //OPENTISSUE_CORE_CONTAINERS_MESH_POLYMESH_UTIL_POLYMESH_IS_BOUNDARY_H 00080 #endif