This example shows how to
- load a surface mesh from a file;
- save a surface mesh into a file.
27#include <easy3d/core/surface_mesh.h>
28#include <easy3d/fileio/surface_mesh_io.h>
29#include <easy3d/util/resource.h>
30#include <easy3d/util/initializer.h>
42int main(
int argc,
char** argv) {
47 const std::string file_name = resource::directory() +
"/data/sphere.obj";
50 LOG(ERROR) <<
"failed to load model. Please make sure the file exists and format is correct.";
53 std::cout <<
"mesh loaded. " << std::endl;
54 std::cout <<
"\tvertices: " << mesh->n_vertices() << std::endl;
55 std::cout <<
"\tedges: " << mesh->n_edges() << std::endl;
56 std::cout <<
"\tfaces: " << mesh->n_faces() << std::endl;
63 const std::string save_file_name =
"./sphere-copy.obj";
64 if (SurfaceMeshIO::save(save_file_name, mesh))
65 std::cout <<
"mesh saved to \'" << save_file_name <<
"\'" << std::endl;
67 std::cerr <<
"failed create the new file" << std::endl;
A halfedge data structure for polygonal meshes of 2-manifold.
Definition surface_mesh.h:51
Definition collider.cpp:182