|
Easy3D 3.0.0
|
Loading a Graph from a PLY file and saving it back out with GraphIO.
Overview
The graph counterpart of Tutorial_103 (point clouds) and Tutorial_107 (surface meshes). This console program loads the bundled "graph.ply", prints its vertex and edge counts, leaves a placeholder for processing, and writes a copy "graph-copy.ply". It follows the same load -> use -> save -> free lifecycle as the other I/O tutorials.
The technique
GraphIO currently supports only the PLY format. PLY (the Polygon File Format, from Stanford) is a flexible, self-describing format: a header declares the elements and their properties, followed by the data, in ASCII or binary. For a graph it stores the vertex positions and the edge list (pairs of vertex indices), which is exactly the 1D connectivity a Graph needs. As with the other loaders, load() returns std::shared_ptr<Graph> (nullptr on failure), and save() returns a bool indicating success. Because only PLY is supported, both the input and output files use the ".ply" extension.
Easy3D API
Running it
Console-only. It prints "graph loaded." with the vertex and edge counts, then "graph saved to './graph-copy.ply'". The copy is written to the current working directory.