|
Easy3D 3.0.0
|
Loading a SurfaceMesh from a file and saving it to another with SurfaceMeshIO.
Overview
The mesh counterpart of Tutorial_103_PointCloud_IO. This console program loads the bundled "sphere.obj", reports its vertex/edge/face counts, leaves a placeholder where you would process the mesh, and writes it back out as "sphere-copy.obj". It shows the standard load -> use -> save -> free lifecycle for a surface mesh.
The technique
SurfaceMeshIO dispatches on the file extension and supports several mesh formats (ply, obj, off, stl, poly), in ASCII or binary as the format allows. The Wavefront OBJ used here lists vertex positions and face indices (and optionally normals/texture coordinates). On load, Easy3D reconstructs the halfedge connectivity from those faces — building a consistent, orientable 2-manifold — so the result is immediately ready for the adjacency queries of Tutorial_105. Two ownership/return conventions matter: load() returns std::shared_ptr<SurfaceMesh> (nullptr on failure), and save() returns a bool telling you whether the write succeeded. The output extension determines the format written.
Easy3D API
Running it
Console-only. It prints "mesh loaded." followed by the vertex, edge and face counts, then "mesh saved to './sphere-copy.obj'". The copy is written to the current working directory and can be re-loaded by any OBJ-capable tool.