| 86 | } |
| 87 | |
| 88 | void VoxelMap::AddPoints(const Vector3dVector &points) { |
| 89 | std::for_each(points.cbegin(), points.cend(), [&](const Eigen::Vector3d &point) { |
| 90 | const Voxel voxel = ToVoxelCoordinates(point, voxel_size_); |
| 91 | const auto [it, inserted] = map_.try_emplace(voxel, VoxelBlock()); |
| 92 | if (!inserted) { |
| 93 | const VoxelBlock &voxel_block = it->second; |
| 94 | if (voxel_block.size() == max_points_per_normal_computation || |
| 95 | std::any_of(voxel_block.cbegin(), voxel_block.cend(), |
| 96 | [&](const Eigen::Vector3d &voxel_point) { |
| 97 | return (voxel_point - point).norm() < map_resolution_; |
| 98 | })) { |
| 99 | return; |
| 100 | } |
| 101 | } |
| 102 | it->second.emplace_back(point); |
| 103 | }); |
| 104 | } |
| 105 | |
| 106 | Vector3dVector VoxelMap::Pointcloud() const { |
| 107 | Vector3dVector points; |
no test coverage detected