This example shows how to load a polyhedral mesh from a file and save a polyhedral mesh into a file.
27#include <easy3d/core/poly_mesh.h>
28#include <easy3d/fileio/poly_mesh_io.h>
29#include <easy3d/util/resource.h>
30#include <easy3d/util/initializer.h>
40int main(
int argc,
char** argv) {
45 const std::string file_name = resource::directory() +
"/data/sphere.plm";
46 PolyMesh* mesh = PolyMeshIO::load(file_name);
48 LOG(ERROR) <<
"failed to load model. Please make sure the file exists and format is correct.";
51 std::cout <<
"mesh loaded. " << std::endl;
52 std::cout <<
"\tvertices: " << mesh->n_vertices() << std::endl;
53 std::cout <<
"\tedges: " << mesh->n_edges() << std::endl;
54 std::cout <<
"\tfaces: " << mesh->n_faces() << std::endl;
55 std::cout <<
"\tcells: " << mesh->n_cells() << std::endl;
62 const std::string save_file_name =
"./sphere-copy.plm";
63 if (PolyMeshIO::save(save_file_name, mesh))
64 std::cout <<
"mesh saved to \'" << save_file_name <<
"\'" << std::endl;
66 std::cerr <<
"failed create the new file" << std::endl;
Data structure representing a polyhedral mesh.
Definition poly_mesh.h:49
Definition collider.cpp:182