00001 #ifndef OPENTISSUE_CORE_CONTAINERS_MESH_COMMON_UTIL_MESH_COMPUTE_MESH_CENTER_H 00002 #define OPENTISSUE_CORE_CONTAINERS_MESH_COMMON_UTIL_MESH_COMPUTE_MESH_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 #include <OpenTissue/core/containers/mesh/common/util/mesh_compute_mesh_minimum_coord.h> 00013 #include <OpenTissue/core/containers/mesh/common/util/mesh_compute_mesh_maximum_coord.h> 00014 00015 namespace OpenTissue 00016 { 00017 namespace mesh 00018 { 00019 00020 // template<typename mesh_type, typename vector3_type> 00021 template<typename mesh_type> 00022 void compute_mesh_center(mesh_type const & mesh 00023 , typename mesh_type::math_types::vector3_type & center) 00024 { 00025 typedef typename mesh_type::math_types math_types; 00026 typedef typename math_types::value_traits value_traits; 00027 typedef typename math_types::vector3_type vector3_type; 00028 typedef typename math_types::real_type real_type; 00029 00030 vector3_type min_coord; 00031 vector3_type max_coord; 00032 mesh::compute_mesh_minimum_coord(mesh,min_coord); 00033 mesh::compute_mesh_maximum_coord(mesh,max_coord); 00034 center = (max_coord+min_coord)/value_traits::two(); 00035 } 00036 00037 } // namespace mesh 00038 } // namespace OpenTissue 00039 00040 //OPENTISSUE_CORE_CONTAINERS_MESH_COMMON_UTIL_MESH_COMPUTE_MESH_CENTER_H 00041 #endif