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()(
typename Mesh::Vertex& _v)
57 typename Mesh::VertexHandle vh( mesh_.handle(_v) );
58 typename Mesh::VertexVertexIter vv_it;
59 typename Mesh::Scalar valence(0.0);
61 mesh_.property(cog_, vh) =
typename Mesh::Point(0.0, 0.0, 0.0);
63 for (vv_it=mesh_.vv_iter(vh); vv_it; ++vv_it)
65 mesh_.property(cog_, vh) += mesh_.point( vv_it );
69 mesh_.property(cog_, mesh_.handle(_v) ) /= valence;
81 SetCOG(Mesh& _mesh, Property_cog& _cog)
82 : mesh_(_mesh), cog_(_cog)
85 void operator()(
typename Mesh::Vertex& _v)
87 typename Mesh::VertexHandle vh(mesh_.handle(_v));
89 if (!mesh_.is_boundary(vh))
90 mesh_.set_point( vh, mesh_.property(cog_, vh) );
Handle representing a vertex property.
Definition: Property.hh:487