4 #include <OpenMesh/Core/IO/MeshIO.hh> 5 #include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh> 10 int main(
int argc,
char **argv)
18 std::cerr <<
"Usage: " << argv[0] <<
" #iterations infile outfile\n";
26 std::cerr <<
"Error: Cannot read mesh from " << argv[2] << std::endl;
32 std::vector<MyMesh::Point> cogs;
33 std::vector<MyMesh::Point>::iterator cog_it;
34 cogs.reserve(mesh.n_vertices());
38 MyMesh::VertexIter v_it, v_end(mesh.vertices_end());
42 unsigned int i, N(atoi(argv[1]));
48 for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
50 cog[0] = cog[1] = cog[2] = valence = 0.0;
52 for (vv_it=mesh.vv_iter( v_it ); vv_it; ++vv_it)
54 cog += mesh.point( vv_it );
58 cogs.push_back(cog / valence);
61 for (v_it=mesh.vertices_begin(), cog_it=cogs.begin();
62 v_it!=v_end; ++v_it, ++cog_it)
63 if ( !mesh.is_boundary( v_it ) )
64 mesh.set_point( v_it, *cog_it );
71 std::cerr <<
"Error: cannot write mesh to " << argv[3] << std::endl;
bool read_mesh(Mesh &_mesh, const std::string &_filename)
Read a mesh from file _filename.
Kernel::VertexVertexIter VertexVertexIter
Circulator.
Kernel::Point Point
Coordinate type.
Kernel::Scalar Scalar
Scalar type.
bool write_mesh(const Mesh &_mesh, const std::string &_filename, Options _opt=Options::Default, std::streamsize _precision=6)
Write a mesh to the file _filename.