4 #include <OpenMesh/Core/IO/MeshIO.hh> 5 #include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh> 17 VertexT() : cog_( Point(0.0f, 0.0f, 0.0f ) ) { }
19 const Point& cog()
const {
return cog_; }
20 void set_cog(
const Point& _p) { cog_ = _p; }
28 #define SIZEOF( entity,b ) \ 29 std::cout << _prefix << "size of " << #entity << ": " \ 30 << sizeof( entity ) << std::endl; \ 33 template <
typename Mesh>
34 void print_size(
const std::string& _prefix =
"")
41 std::cout << _prefix <<
"total: " << total << std::endl;
48 int main(
int argc,
char **argv)
53 if (argc < 4 || argc > 5)
55 std::cerr <<
"Usage: " << argv[0] <<
" [-s] #iterations infile outfile\n";
65 if (std::string(
"-s")==argv[idx-1])
67 std::cout <<
"Enhanced mesh size statistics\n";
68 print_size<MyMesh>(
" ");
70 std::cout <<
"Default mesh size statistics\n";
71 print_size<MyMesh2>(
" ");
79 std::cout<<
" Input mesh: " << argv[idx] << std::endl;
82 std::cerr <<
"Error: Cannot read mesh from " << argv[idx] << std::endl;
89 MyMesh::VertexIter v_it, v_end(mesh.vertices_end());
93 unsigned int i, N(atoi(argv[idx-1]));
95 std::cout<<
"Smooth mesh " << N <<
" times\n";
99 for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
101 cog[0] = cog[1] = cog[2] = valence = 0.0;
103 for (vv_it=mesh.vv_iter(v_it); vv_it.is_valid(); ++vv_it)
105 cog += mesh.point( *vv_it );
109 mesh.data(v_it).set_cog(cog / valence);
112 for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
113 if (!mesh.is_boundary(*v_it))
114 mesh.set_point( *v_it, mesh.data(v_it).cog());
119 std::cout<<
"Output mesh: " << argv[idx+1] << std::endl;
123 std::cerr <<
"Error: cannot write mesh to " << argv[idx+1] << std::endl;
Kernel::Edge Edge
Edge type.
Kernel::Halfedge Halfedge
Halfedge type.
Kernel::Vertex Vertex
Vertex type.
bool read_mesh(Mesh &_mesh, const std::string &_filename)
Read a mesh from file _filename.
Kernel::VertexVertexIter VertexVertexIter
Circulator.
Kernel::Face Face
Face type.
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.