Search code examples
c++11visual-c++c++14point-cloud-librarypoint-clouds

How can create a vector of Point Cloud as Buffer


What the efficient way to create a vector of point clouds used as a buffer in order to store multi-scanning point clouds


Solution

  • Starting C++11, you can use std::vector as an RAII buffer. Instead of allocating the space yourself using new and then having to delete the pointer to avoid memory leaks, you can simply create an std::vector and pre-allocate it so that it can be used a a buffer: (some of this is some pseudo code since I'm not familiar with point clouds)

    #include <vector>
    
    constexpr unsigned int numberOfPoints = 100;
    std::vector<point_clouds> buffer(numberOfPoints);
    scan_point_clound_func(buffer.data(), buffer.size());
    point_cloud p = buffer[0];