00001 #ifndef OPENTISSUE_CORE_CONTAINERS_MESH_COMMON_UTIL_MESH_COMPUTE_FACE_CENTER_H 00002 #define OPENTISSUE_CORE_CONTAINERS_MESH_COMMON_UTIL_MESH_COMPUTE_FACE_CENTER_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 mesh 00015 { 00016 template<typename face_type,typename vector3_type> 00017 void compute_face_center(face_type const & f, vector3_type & center) 00018 { 00019 typedef typename face_type::mesh_type mesh_type; 00020 typedef typename mesh_type::face_vertex_circulator face_vertex_circulator; 00021 00022 typedef typename mesh_type::math_types math_types; 00023 typedef typename math_types::real_type real_type; 00024 00025 center.clear(); 00026 face_vertex_circulator v(f),end; 00027 for(;v!=end;++v) 00028 center += v->m_coord; 00029 center /= static_cast<real_type>(valency(f)); 00030 } 00031 00032 } // namespace mesh 00033 } // namespace OpenTissue 00034 00035 //OPENTISSUE_CORE_CONTAINERS_MESH_COMMON_UTIL_MESH_COMPUTE_FACE_CENTER_H 00036 #endif