00001 #ifndef OPENTISSUE_CORE_CONTAINERS_MESH_POLYMESH_UTIL_POLYMESH_IS_SADDLE_POINT_H 00002 #define OPENTISSUE_CORE_CONTAINERS_MESH_POLYMESH_UTIL_POLYMESH_IS_SADDLE_POINT_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_vertex.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 namespace OpenTissue 00017 { 00018 namespace polymesh 00019 { 00020 00021 template<typename mesh_type,typename real_type> 00022 bool is_saddle_point(PolyMeshVertex<mesh_type> const & v,real_type const & tolerance) 00023 { 00024 typedef typename mesh_type::vertex_halfedge_circulator vertex_halfedge_circulator; 00025 00026 if(valency(v)==0) 00027 return false; 00028 00029 bool convex = false; 00030 bool concave = false; 00031 00032 vertex_halfedge_circulator h(v), end; 00033 for(;h!=end;++h) 00034 { 00035 if( is_convex( *h, tolerance ) ) 00036 convex = true; 00037 else 00038 concave = true; 00039 if(convex && concave) 00040 return true; 00041 } 00042 return false; 00043 } 00044 00045 template<typename mesh_type> 00046 bool is_saddle_point(PolyMeshVertex<mesh_type> const & v) 00047 { 00048 typedef typename mesh_type::math_types math_types; 00049 typedef typename math_types::value_traits value_traits; 00050 00051 return is_saddle_point(v,value_traits::zero()); 00052 } 00053 00054 } // namespace polymesh 00055 } // namespace OpenTissue 00056 00057 //OPENTISSUE_CORE_CONTAINERS_MESH_POLYMESH_UTIL_POLYMESH_IS_SADDLE_POINT_H 00058 #endif