This example shows how to load a point cloud from a file and save a point cloud to a file.
27#include <easy3d/core/point_cloud.h>
28#include <easy3d/fileio/point_cloud_io.h>
29#include <easy3d/util/resource.h>
30#include <easy3d/util/initializer.h>
41int main(
int argc,
char** argv) {
46 PointCloud* cloud = PointCloudIO::load(resource::directory() +
"/data/bunny.bin");
48 LOG(ERROR) <<
"failed to load model. Please make sure the file exists and format is correct.";
52 std::cout <<
"point cloud has " << cloud->
n_vertices() <<
" points" << std::endl;
57 std::ofstream output(
"./bunny-copy.txt");
58 if (output.is_open()) {
65 std::cout <<
"saving the point cloud..." << std::endl;
70 output <<
" " << normals[v];
72 output <<
" " << colors[v];
75 std::cout <<
"point cloud saved to './bunny-copy.txt'" << std::endl;
Vertex property of type T.
Definition point_cloud.h:151
A data structure for point clouds.
Definition point_cloud.h:45
VertexContainer vertices() const
Returns vertex container for C++11 range-based for-loops.
Definition point_cloud.h:671
VertexProperty< T > get_vertex_property(const std::string &name) const
Get the vertex property named name of type T.
Definition point_cloud.h:513
unsigned int n_vertices() const
Returns number of vertices in the cloud.
Definition point_cloud.h:422
Definition collider.cpp:182