MCPcopy Create free account
hub / github.com/Pamphlett/Outram / init_voxel_map

Method init_voxel_map

src/STDesc.cpp:750–796  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

748}
749
750void STDescManager::init_voxel_map(
751 const pcl::PointCloud<pcl::PointXYZI>::Ptr &input_cloud,
752 std::unordered_map<VOXEL_LOC, OctoTree *> &voxel_map) {
753 uint plsize = input_cloud->size();
754 for (uint i = 0; i < plsize; i++) {
755 Eigen::Vector3d p_c(input_cloud->points[i].x, input_cloud->points[i].y,
756 input_cloud->points[i].z);
757 double loc_xyz[3];
758 for (int j = 0; j < 3; j++) {
759 loc_xyz[j] = p_c[j] / config_setting_.voxel_size_;
760 if (loc_xyz[j] < 0) {
761 loc_xyz[j] -= 1.0;
762 }
763 }
764 VOXEL_LOC position((int64_t)loc_xyz[0], (int64_t)loc_xyz[1],
765 (int64_t)loc_xyz[2]);
766 auto iter = voxel_map.find(position);
767 if (iter != voxel_map.end()) {
768 voxel_map[position]->voxel_points_.push_back(p_c);
769 } else {
770 OctoTree *octo_tree = new OctoTree(config_setting_);
771 voxel_map[position] = octo_tree;
772 voxel_map[position]->voxel_points_.push_back(p_c);
773 }
774 }
775 std::vector<std::unordered_map<VOXEL_LOC, OctoTree *>::iterator> iter_list;
776 std::vector<size_t> index;
777 size_t i = 0;
778 for (auto iter = voxel_map.begin(); iter != voxel_map.end(); ++iter) {
779 index.push_back(i);
780 i++;
781 iter_list.push_back(iter);
782 }
783 // speed up initialization
784 // #ifdef MP_EN
785 // omp_set_num_threads(MP_PROC_NUM);
786 // std::cout << "omp num:" << MP_PROC_NUM << std::endl;
787 // #pragma omp parallel for
788 // #endif
789 for (int i = 0; i < index.size(); i++) {
790 iter_list[i]->second->init_octo_tree();
791 }
792 // std::cout << "voxel num:" << index.size() << std::endl;
793 // std::for_each(
794 // std::execution::par_unseq, index.begin(), index.end(),
795 // [&](const size_t &i) { iter_list[i]->second->init_octo_tree(); });
796}
797
798void STDescManager::build_connection(
799 std::unordered_map<VOXEL_LOC, OctoTree *> &voxel_map) {

Callers

nothing calls this directly

Calls 5

init_octo_treeMethod · 0.80
sizeMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected