Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
smooth.cc
1 #include <iostream>
2 #include <vector>
3 // -------------------- OpenMesh
4 #include <OpenMesh/Core/IO/MeshIO.hh>
5 #include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
6 // --------------------
7 #include "smooth_algo.hh"
8 
9 
10 // ----------------------------------------------------------------------------
11 
12 #ifndef DOXY_IGNORE_THIS
13 
14 struct MyTraits : public OpenMesh::DefaultTraits
15 {
16  HalfedgeAttributes(OpenMesh::Attributes::PrevHalfedge);
17 };
18 
19 #endif
20 
22 
23 
24 // ----------------------------------------------------------------------------
25 
26 int main(int argc, char **argv)
27 {
28  MyMesh mesh;
29 
30 
31  // check command line options
32  if (argc != 4)
33  {
34  std::cerr << "Usage: " << argv[0] << " #iterations infile outfile\n";
35  return 1;
36  }
37 
38 
39  // read mesh from stdin
40  if ( ! OpenMesh::IO::read_mesh(mesh, argv[2]) )
41  {
42  std::cerr << "Error: Cannot read mesh from " << argv[2] << std::endl;
43  return 1;
44  }
45 
46 
47  // smoothing mesh argv[1] times
48  SmootherT<MyMesh> smoother(mesh);
49  smoother.smooth(atoi(argv[1]));
50 
51 
52  // write mesh to stdout
53  if ( ! OpenMesh::IO::write_mesh(mesh, argv[3]) )
54  {
55  std::cerr << "Error: cannot write mesh to " << argv[3] << std::endl;
56  return 1;
57  }
58  return 0;
59 }
bool read_mesh(Mesh &_mesh, const std::string &_filename)
Read a mesh from file _filename.
Definition: MeshIO.hh:104
Add storage for previous halfedge (halfedges). The bit is set by default in the DefaultTraits.
Definition: Attributes.hh:89
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.
Definition: MeshIO.hh:199