2 #include <OpenMesh/Core/Utils/Property.hh>
4 #ifndef DOXY_IGNORE_THIS
6 template <
class Mesh>
class SmootherT
10 typedef typename Mesh::Point cog_t;
16 SmootherT(Mesh& _mesh)
19 mesh_.add_property( cog_ );
24 mesh_.remove_property( cog_ );
28 void smooth(
unsigned int _iterations)
30 for (
unsigned int i=0; i < _iterations; ++i)
32 std::for_each(mesh_.vertices_begin(),
34 ComputeCOG(mesh_, cog_));
36 std::for_each(mesh_.vertices_begin(),
51 ComputeCOG(Mesh& _mesh, Property_cog& _cog)
52 : mesh_(_mesh), cog_(_cog)
55 void operator()(
const typename Mesh::VertexHandle& _vh)
57 typename Mesh::VertexVertexIter vv_it;
58 typename Mesh::Scalar valence(0.0);
60 mesh_.property(cog_, _vh) =
typename Mesh::Point(0.0, 0.0, 0.0);
62 for (vv_it=mesh_.vv_iter(_vh); vv_it.is_valid(); ++vv_it)
64 mesh_.property(cog_, _vh) += mesh_.point( *vv_it );
68 mesh_.property(cog_, _vh ) /= valence;
80 SetCOG(Mesh& _mesh, Property_cog& _cog)
81 : mesh_(_mesh), cog_(_cog)
84 void operator()(
const typename Mesh::VertexHandle& _vh)
87 if (!mesh_.is_boundary(_vh))
88 mesh_.set_point( _vh, mesh_.property(cog_, _vh) );
Handle representing a vertex property.
Definition: Property.hh:487