|
Easy3D 3.0.0
|
Loading a point cloud from disk and writing it back out, including a hand-rolled text export.
Overview
This console tutorial covers file input/output for PointCloud. It loads the bundled "bunny" cloud, reports how many points it contains, and then exports the data to a plain-text file, one point per line. It complements Tutorial_102_PointCloud_Property by showing that the same named properties used to store attributes are also what get read from and written to files.
The technique
Easy3D dispatches on the file extension: PointCloudIO::load()/save() understand several point formats (bin, xyz/bxyz, ply, las/laz, vg/bvg), so the same call works regardless of the concrete format. Here we load Easy3D's compact binary ".bin" file. For the export we deliberately do NOT call save(); instead we stream the attributes ourselves to demonstrate that a loaded cloud is just properties we can iterate. Each output line holds the xyz coordinates, followed by the normal and the color when those properties exist. Because normals/colors are optional, we test each property handle for validity before dereferencing it: get_vertex_property<T>() returns an invalid (null) handle when the name is absent, and a VertexProperty converts to bool so that "if (normals)" is a safe existence check.
Easy3D API
Running it
Console-only. It prints the loaded point count, then "saving the point cloud..." and "point cloud saved to './bunny-copy.txt'". The export is written to the current working directory; open it to see one "x y z [nx ny nz] [r g b]" line per point.