49 #ifndef SMOOTH_MESH_HH 50 #define SMOOTH_MESH_HH 54 #include <OpenMesh/Core/Utils/Property.hh> 60 template <
class _Mesh,
class _PropertyHandle>
61 void smooth_mesh_property(
unsigned int _n_iters, _Mesh& _m, _PropertyHandle _pph)
63 typedef typename _PropertyHandle::Value Value;
65 std::vector<Value> temp_values(_m.n_vertices());
67 for (
unsigned int i=0; i < _n_iters; ++i)
69 for (
typename _Mesh::ConstVertexIter cv_it = _m.vertices_begin();
70 cv_it != _m.vertices_end(); ++cv_it)
72 unsigned int valence = 0;
74 Value& temp_value = temp_values[cv_it->idx()];
76 temp_value.vectorize(0);
78 for (
typename _Mesh::ConstVertexVertexIter cvv_it = _m.cvv_iter(cv_it);
81 temp_value += _m.property(_pph,cvv_it);
86 temp_value *= (
typename Value::value_type)(1.0 / valence);
90 temp_value = _m.property(_pph, cv_it);
94 for (
typename _Mesh::ConstVertexIter cv_it = _m.vertices_begin();
95 cv_it != _m.vertices_end(); ++cv_it)
97 _m.property(_pph,cv_it) = temp_values[cv_it->idx()];
102 template <
class _Mesh>
103 void smooth_mesh(_Mesh& _m, uint _n_iters)
105 smooth_mesh_property(_n_iters, _m, _m.points_pph());
110 #endif//SMOOTH_MESH_HH