如何有效地处理3D体素?

use*_*780 5 c++ 3d computational-geometry

我有一个拥有数百万点的3D点云.我想将这些点存储在3D体素空间中.沿坐标轴的体素数大于3000(x),4000(y),1500(z),总共3000*4000*1500体素.我需要存放在体素中; 最大点数,最小高度,最大高度和centorid.但是,90%的体素都是空的.因此存储它需要大量内存.实际上,我想在以后搜索每个体素的26个相邻体素.那么在体素空间中存储这些数据并有效访问这些数据的最佳方法是什么?

在性能方面,创建一个多维数组并不是最好的解决方案......请提出任何提示?

jus*_*tin 1

一种方法是使用集合中的数据来支持实际数据。

为了显示:

struct t_voxel {
  size_t nPoints, minHeight, maxHeight, centorid;
};

struct t_voxel_id {
  uint16_t index;
};

// one dimension
class t_voxel_collection {
  // the actual voxel data needed for the indices represented by the collection of voxelId
  std::vector<t_voxel> d_voxel;
  // here, empty voxel is designated by t_voxel.index = 0
  // this collection is your primary array representation
  // these elements just refer to a unique or shared index in this->d_voxel
  std::vector<t_voxel_id> d_voxelId;
public:
  // >> the interface to access and set, which abstracts the backing collection.
  // and prohibits the client from accessing the actual data.

  t_voxel get(const size_t& idx) const {
    return this->d_voxel[this->d_voxelId[idx].index];
  }
  // ...
};
Run Code Online (Sandbox Code Playgroud)

通过这种方式,您可以大幅降低内存消耗(假设您看到了这个方向)。

这不是一个完整的答案,但在这种情况下可能会有所帮助。

有多种方法可以进一步优化和共享此集合中的体素数据,具体取决于您的用途。