Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_CONTAINERS_MESH_POLYMESH_UTIL_MESH_LAPLACIAN_SMOOTH_H
00002 #define OPENTISSUE_CORE_CONTAINERS_MESH_POLYMESH_UTIL_MESH_LAPLACIAN_SMOOTH_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 namespace OpenTissue
00013 {
00014 namespace polymesh
00015 {
00016
00023 template<typename mesh_type>
00024 void laplacian_smooth(
00025 mesh_type & mesh
00026 , double t
00027 )
00028 {
00029 typedef typename mesh_type::math_types math_types;
00030 typedef typename math_types::value_traits value_traits;
00031 typedef typename math_types::vector3_type vector3_type;
00032 typedef typename math_types::real_type real_type;
00033 typedef typename mesh_type::vertex_iterator vertex_iterator;
00034 typedef typename mesh_type::vertex_vertex_circulator vertex_vertex_circulator;
00035
00036 t = std::min(t, 1.0);
00037 double ti = 1.0 - t;
00038
00039 real_type zero = static_cast<real_type>(0.0);
00040
00041 vertex_iterator vend = mesh.vertex_end();
00042 vertex_iterator v = mesh.vertex_begin();
00043 for(;v!=vend;++v)
00044 {
00045 if(is_boundary(*v))
00046 continue;
00047 int n = 0;
00048 vector3_type avg(zero,zero,zero);
00049 vertex_vertex_circulator V(*v),Vend;
00050 for(;V!=Vend;++V,++n)
00051 {
00052 avg += V->m_coord;
00053 }
00054 v->m_coord = t * avg/n + ti * v->m_coord;
00055 }
00056 }
00057
00058 }
00059 }
00060
00061
00062 #endif