00001 #ifndef OPENTISSUE_CORE_CONTAINERS_MESH_POLYMESH_UTIL_POLYMESH_IS_CONCAVE_H 00002 #define OPENTISSUE_CORE_CONTAINERS_MESH_POLYMESH_UTIL_POLYMESH_IS_CONCAVE_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/util/polymesh_dihedral_angle.h> 00013 #include <OpenTissue/core/containers/mesh/polymesh/util/polymesh_valency.h> 00014 #include <OpenTissue/core/containers/mesh/polymesh/util/polymesh_is_convex.h> 00015 00016 #include <functional> // std::less 00017 00018 namespace OpenTissue 00019 { 00020 namespace polymesh 00021 { 00022 00023 template<typename mesh_type,typename real_type> 00024 bool is_concave(PolyMeshHalfEdge<mesh_type> const & e,real_type const & tolerance) 00025 { 00026 real_type radian; 00027 compute_dihedral_angle(e,radian); 00028 if( radian >= tolerance ) 00029 return false; 00030 return true; 00031 } 00032 00033 template<typename mesh_type> 00034 bool is_concave(PolyMeshHalfEdge<mesh_type> const & e) 00035 { 00036 typedef typename mesh_type::math_types::value_traits value_traits; 00037 00038 return is_concave(e,value_traits::zero()); 00039 } 00040 00041 template<typename mesh_type,typename real_type> 00042 bool is_concave(PolyMeshVertex<mesh_type> const & v,real_type const & tolerance) 00043 { 00044 typedef typename mesh_type::vertex_halfedge_circulator vertex_halfedge_circulator; 00045 if(valency(v)==0) 00046 return false; 00047 vertex_halfedge_circulator h(v), end; 00048 for(;h!=end;++h) 00049 { 00050 if( !is_concave(*h,tolerance) ) 00051 return false; 00052 } 00053 return true; 00054 } 00055 00056 template<typename mesh_type> 00057 bool is_concave(PolyMeshVertex<mesh_type> const & v) 00058 { 00059 typedef typename mesh_type::math_types::value_traits value_traits; 00060 00061 return is_concave(v,value_traits::zero()); 00062 } 00063 00064 } // namespace polymesh 00065 } // namespace OpenTissue 00066 00067 //OPENTISSUE_CORE_CONTAINERS_MESH_POLYMESH_UTIL_POLYMESH_IS_CONCAVE_H 00068 #endif