From 5b2339aeb0bc562354c712434cd7b182b687ea92 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Tue, 25 Aug 2020 04:15:22 +0900 Subject: [PATCH 01/12] Compile octree with all options enabled and int64 as indices --- common/include/pcl/common/io.h | 4 +-- common/src/io.cpp | 2 +- .../pcl/octree/impl/octree_pointcloud.hpp | 2 +- .../include/pcl/octree/impl/octree_search.hpp | 33 +++++++++---------- octree/include/pcl/octree/octree_container.h | 14 ++++---- octree/include/pcl/octree/octree_pointcloud.h | 4 +-- .../octree/octree_pointcloud_changedetector.h | 2 +- octree/include/pcl/octree/octree_search.h | 30 ++++++++--------- 8 files changed, 45 insertions(+), 46 deletions(-) diff --git a/common/include/pcl/common/io.h b/common/include/pcl/common/io.h index 33dfaf049e5..ccb6825de37 100644 --- a/common/include/pcl/common/io.h +++ b/common/include/pcl/common/io.h @@ -347,7 +347,7 @@ namespace pcl * \note Assumes unique indices. * \ingroup common */ - template > void + template > void copyPointCloud (const pcl::PointCloud &cloud_in, const IndicesAllocator< IndicesVectorAllocator> &indices, pcl::PointCloud &cloud_out); @@ -392,7 +392,7 @@ namespace pcl * \note Assumes unique indices. * \ingroup common */ - template > void + template > void copyPointCloud (const pcl::PointCloud &cloud_in, const IndicesAllocator &indices, pcl::PointCloud &cloud_out); diff --git a/common/src/io.cpp b/common/src/io.cpp index 9e8e7fc5cdc..838ab1c37a5 100644 --- a/common/src/io.cpp +++ b/common/src/io.cpp @@ -438,7 +438,7 @@ pcl::copyPointCloud ( void pcl::copyPointCloud ( const pcl::PCLPointCloud2 &cloud_in, - const IndicesAllocator< Eigen::aligned_allocator > &indices, + const IndicesAllocator< Eigen::aligned_allocator > &indices, pcl::PCLPointCloud2 &cloud_out) { cloud_out.header = cloud_in.header; diff --git a/octree/include/pcl/octree/impl/octree_pointcloud.hpp b/octree/include/pcl/octree/impl/octree_pointcloud.hpp index 19bced45b1c..12d91b0bddb 100644 --- a/octree/include/pcl/octree/impl/octree_pointcloud.hpp +++ b/octree/include/pcl/octree/impl/octree_pointcloud.hpp @@ -612,7 +612,7 @@ pcl::octree::OctreePointCloud std::size_t leaf_obj_count = (*leaf_node)->getSize(); // copy leaf data - std::vector leafIndices; + Indices leafIndices; leafIndices.reserve(leaf_obj_count); (*leaf_node)->getPointIndices(leafIndices); diff --git a/octree/include/pcl/octree/impl/octree_search.hpp b/octree/include/pcl/octree/impl/octree_search.hpp index 16b98ce0f98..8269cb98dd9 100644 --- a/octree/include/pcl/octree/impl/octree_search.hpp +++ b/octree/include/pcl/octree/impl/octree_search.hpp @@ -48,7 +48,7 @@ namespace octree { template bool OctreePointCloudSearch::voxelSearch( - const PointT& point, std::vector& point_idx_data) + const PointT& point, Indices& point_idx_data) { assert(isFinite(point) && "Invalid (NaN, Inf) point coordinates given to nearestKSearch!"); @@ -71,7 +71,7 @@ OctreePointCloudSearch::voxelSearch( template bool OctreePointCloudSearch::voxelSearch( - const int index, std::vector& point_idx_data) + const int index, Indices& point_idx_data) { const PointT search_point = this->getPointByIndex(index); return (this->voxelSearch(search_point, point_idx_data)); @@ -80,10 +80,7 @@ OctreePointCloudSearch::voxelSearch( template int OctreePointCloudSearch::nearestKSearch( - const PointT& p_q, - int k, - std::vector& k_indices, - std::vector& k_sqr_distances) + const PointT& p_q, int k, Indices& k_indices, std::vector& k_sqr_distances) { assert(this->leaf_count_ > 0); assert(isFinite(p_q) && @@ -123,7 +120,7 @@ OctreePointCloudSearch::nearestKSearch template int OctreePointCloudSearch::nearestKSearch( - int index, int k, std::vector& k_indices, std::vector& k_sqr_distances) + int index, int k, Indices& k_indices, std::vector& k_sqr_distances) { const PointT search_point = this->getPointByIndex(index); return (nearestKSearch(search_point, k, k_indices, k_sqr_distances)); @@ -162,7 +159,7 @@ int OctreePointCloudSearch::radiusSearch( const PointT& p_q, const double radius, - std::vector& k_indices, + Indices& k_indices, std::vector& k_sqr_distances, unsigned int max_nn) const { @@ -191,7 +188,7 @@ int OctreePointCloudSearch::radiusSearch( int index, const double radius, - std::vector& k_indices, + Indices& k_indices, std::vector& k_sqr_distances, unsigned int max_nn) const { @@ -205,7 +202,7 @@ int OctreePointCloudSearch::boxSearch( const Eigen::Vector3f& min_pt, const Eigen::Vector3f& max_pt, - std::vector& k_indices) const + Indices& k_indices) const { OctreeKey key; @@ -290,7 +287,7 @@ OctreePointCloudSearch:: } else { // we reached leaf node level - std::vector decoded_point_vector; + Indices decoded_point_vector; const LeafNode* child_leaf = static_cast(child_node); @@ -338,7 +335,7 @@ OctreePointCloudSearch:: const BranchNode* node, const OctreeKey& key, unsigned int tree_depth, - std::vector& k_indices, + Indices& k_indices, std::vector& k_sqr_distances, unsigned int max_nn) const { @@ -389,7 +386,7 @@ OctreePointCloudSearch:: else { // we reached leaf node level const LeafNode* child_leaf = static_cast(child_node); - std::vector decoded_point_vector; + Indices decoded_point_vector; // decode leaf node into decoded_point_vector (*child_leaf)->getPointIndices(decoded_point_vector); @@ -479,7 +476,7 @@ OctreePointCloudSearch:: } else { // we reached leaf node level - std::vector decoded_point_vector; + Indices decoded_point_vector; const LeafNode* child_leaf = static_cast(child_node); @@ -522,7 +519,7 @@ OctreePointCloudSearch::boxSearchRecur const BranchNode* node, const OctreeKey& key, unsigned int tree_depth, - std::vector& k_indices) const + Indices& k_indices) const { // iterate over all children for (unsigned char child_idx = 0; child_idx < 8; child_idx++) { @@ -563,7 +560,7 @@ OctreePointCloudSearch::boxSearchRecur } else { // we reached leaf node level - std::vector decoded_point_vector; + Indices decoded_point_vector; const LeafNode* child_leaf = static_cast(child_node); @@ -630,7 +627,7 @@ int OctreePointCloudSearch:: getIntersectedVoxelIndices(Eigen::Vector3f origin, Eigen::Vector3f direction, - std::vector& k_indices, + Indices& k_indices, int max_voxel_count) const { OctreeKey key; @@ -867,7 +864,7 @@ OctreePointCloudSearch:: unsigned char a, const OctreeNode* node, const OctreeKey& key, - std::vector& k_indices, + Indices& k_indices, int max_voxel_count) const { if (max_x < 0.0 || max_y < 0.0 || max_z < 0.0) diff --git a/octree/include/pcl/octree/octree_container.h b/octree/include/pcl/octree/octree_container.h index c4655b7cfdf..4452f0ca04a 100644 --- a/octree/include/pcl/octree/octree_container.h +++ b/octree/include/pcl/octree/octree_container.h @@ -38,6 +38,8 @@ #pragma once +#include + #include #include #include @@ -102,7 +104,7 @@ class OctreeContainerBase { * data. \ */ void - getPointIndices(std::vector&) const + getPointIndices(Indices&) const {} }; @@ -157,7 +159,7 @@ class OctreeContainerEmpty : public OctreeContainerBase { * data. */ void - getPointIndices(std::vector&) const + getPointIndices(Indices&) const {} }; @@ -216,7 +218,7 @@ class OctreeContainerPointIndex : public OctreeContainerBase { * data vector */ void - getPointIndices(std::vector& data_vector_arg) const + getPointIndices(Indices& data_vector_arg) const { if (data_ >= 0) data_vector_arg.push_back(data_); @@ -295,7 +297,7 @@ class OctreeContainerPointIndices : public OctreeContainerBase { * within data vector */ void - getPointIndices(std::vector& data_vector_arg) const + getPointIndices(Indices& data_vector_arg) const { data_vector_arg.insert( data_vector_arg.end(), leafDataTVector_.begin(), leafDataTVector_.end()); @@ -305,7 +307,7 @@ class OctreeContainerPointIndices : public OctreeContainerBase { * of point indices. * \return reference to vector of point indices to be stored within data vector */ - std::vector& + Indices& getPointIndicesVector() { return leafDataTVector_; @@ -329,7 +331,7 @@ class OctreeContainerPointIndices : public OctreeContainerBase { protected: /** \brief Leaf node DataT vector. */ - std::vector leafDataTVector_; + Indices leafDataTVector_; }; } // namespace octree diff --git a/octree/include/pcl/octree/octree_pointcloud.h b/octree/include/pcl/octree/octree_pointcloud.h index 4f66675c530..41e12709cc6 100644 --- a/octree/include/pcl/octree/octree_pointcloud.h +++ b/octree/include/pcl/octree/octree_pointcloud.h @@ -82,8 +82,8 @@ class OctreePointCloud : public OctreeT { OctreePointCloud(const double resolution_arg); // public typedefs - using IndicesPtr = shared_ptr>; - using IndicesConstPtr = shared_ptr>; + using IndicesPtr = shared_ptr; + using IndicesConstPtr = shared_ptr; using PointCloud = pcl::PointCloud; using PointCloudPtr = typename PointCloud::Ptr; diff --git a/octree/include/pcl/octree/octree_pointcloud_changedetector.h b/octree/include/pcl/octree/octree_pointcloud_changedetector.h index 902dfd2c9d5..fd06d3beca6 100644 --- a/octree/include/pcl/octree/octree_pointcloud_changedetector.h +++ b/octree/include/pcl/octree/octree_pointcloud_changedetector.h @@ -91,7 +91,7 @@ class OctreePointCloudChangeDetector * \return number of point indices */ std::size_t - getPointIndicesFromNewVoxels(std::vector& indicesVector_arg, + getPointIndicesFromNewVoxels(Indices& indicesVector_arg, const int minPointsPerLeaf_arg = 0) { diff --git a/octree/include/pcl/octree/octree_search.h b/octree/include/pcl/octree/octree_search.h index 83d30c6f1d3..6ea74d9e643 100644 --- a/octree/include/pcl/octree/octree_search.h +++ b/octree/include/pcl/octree/octree_search.h @@ -58,8 +58,8 @@ class OctreePointCloudSearch : public OctreePointCloud { public: // public typedefs - using IndicesPtr = shared_ptr>; - using IndicesConstPtr = shared_ptr>; + using IndicesPtr = shared_ptr; + using IndicesConstPtr = shared_ptr; using PointCloud = pcl::PointCloud; using PointCloudPtr = typename PointCloud::Ptr; @@ -91,7 +91,7 @@ class OctreePointCloudSearch * \return "true" if leaf node exist; "false" otherwise */ bool - voxelSearch(const PointT& point, std::vector& point_idx_data); + voxelSearch(const PointT& point, Indices& point_idx_data); /** \brief Search for neighbors within a voxel at given point referenced by a point * index @@ -100,7 +100,7 @@ class OctreePointCloudSearch * \return "true" if leaf node exist; "false" otherwise */ bool - voxelSearch(const int index, std::vector& point_idx_data); + voxelSearch(const int index, Indices& point_idx_data); /** \brief Search for k-nearest neighbors at the query point. * \param[in] cloud the point cloud data @@ -116,7 +116,7 @@ class OctreePointCloudSearch nearestKSearch(const PointCloud& cloud, int index, int k, - std::vector& k_indices, + Indices& k_indices, std::vector& k_sqr_distances) { return (nearestKSearch(cloud[index], k, k_indices, k_sqr_distances)); @@ -134,7 +134,7 @@ class OctreePointCloudSearch int nearestKSearch(const PointT& p_q, int k, - std::vector& k_indices, + Indices& k_indices, std::vector& k_sqr_distances); /** \brief Search for k-nearest neighbors at query point @@ -151,7 +151,7 @@ class OctreePointCloudSearch int nearestKSearch(int index, int k, - std::vector& k_indices, + Indices& k_indices, std::vector& k_sqr_distances); /** \brief Search for approx. nearest neighbor at the query point. @@ -203,7 +203,7 @@ class OctreePointCloudSearch radiusSearch(const PointCloud& cloud, int index, double radius, - std::vector& k_indices, + Indices& k_indices, std::vector& k_sqr_distances, unsigned int max_nn = 0) { @@ -222,7 +222,7 @@ class OctreePointCloudSearch int radiusSearch(const PointT& p_q, const double radius, - std::vector& k_indices, + Indices& k_indices, std::vector& k_sqr_distances, unsigned int max_nn = 0) const; @@ -240,7 +240,7 @@ class OctreePointCloudSearch int radiusSearch(int index, const double radius, - std::vector& k_indices, + Indices& k_indices, std::vector& k_sqr_distances, unsigned int max_nn = 0) const; @@ -270,7 +270,7 @@ class OctreePointCloudSearch int getIntersectedVoxelIndices(Eigen::Vector3f origin, Eigen::Vector3f direction, - std::vector& k_indices, + Indices& k_indices, int max_voxel_count = 0) const; /** \brief Search for points within rectangular search area @@ -283,7 +283,7 @@ class OctreePointCloudSearch int boxSearch(const Eigen::Vector3f& min_pt, const Eigen::Vector3f& max_pt, - std::vector& k_indices) const; + Indices& k_indices) const; protected: ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -389,7 +389,7 @@ class OctreePointCloudSearch const BranchNode* node, const OctreeKey& key, unsigned int tree_depth, - std::vector& k_indices, + Indices& k_indices, std::vector& k_sqr_distances, unsigned int max_nn) const; @@ -477,7 +477,7 @@ class OctreePointCloudSearch const BranchNode* node, const OctreeKey& key, unsigned int tree_depth, - std::vector& k_indices) const; + Indices& k_indices) const; /** \brief Recursively search the tree for all intersected leaf nodes and return a * vector of indices. This algorithm is based off the paper An Efficient Parametric @@ -506,7 +506,7 @@ class OctreePointCloudSearch unsigned char a, const OctreeNode* node, const OctreeKey& key, - std::vector& k_indices, + Indices& k_indices, int max_voxel_count) const; /** \brief Initialize raytracing algorithm From 9c49ead861079120d6d330831a3b59db5837157b Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Wed, 26 Aug 2020 10:37:03 +0900 Subject: [PATCH 02/12] Octree PointCloud checked --- .../pcl/octree/impl/octree_pointcloud.hpp | 37 ++++----- .../impl/octree_pointcloud_adjacency.hpp | 4 +- .../include/pcl/octree/impl/octree_search.hpp | 81 ++++++++++--------- octree/include/pcl/octree/octree_pointcloud.h | 16 ++-- .../pcl/octree/octree_pointcloud_adjacency.h | 2 +- .../octree_pointcloud_adjacency_container.h | 4 +- .../pcl/octree/octree_pointcloud_density.h | 10 +-- .../octree/octree_pointcloud_voxelcentroid.h | 11 +-- octree/include/pcl/octree/octree_search.h | 70 ++++++++-------- 9 files changed, 118 insertions(+), 117 deletions(-) diff --git a/octree/include/pcl/octree/impl/octree_pointcloud.hpp b/octree/include/pcl/octree/impl/octree_pointcloud.hpp index 12d91b0bddb..c467417f6dc 100644 --- a/octree/include/pcl/octree/impl/octree_pointcloud.hpp +++ b/octree/include/pcl/octree/impl/octree_pointcloud.hpp @@ -41,6 +41,7 @@ #include #include // for pcl::isFinite #include +#include #include @@ -78,8 +79,8 @@ pcl::octree::OctreePointCloud addPointsFromInputCloud() { if (indices_) { - for (const int& index : *indices_) { - assert((index >= 0) && (index < static_cast(input_->size()))); + for (const auto& index : *indices_) { + assert((index >= 0) && (index < input_->size())); if (isFinite((*input_)[index])) { // add points to octree @@ -88,10 +89,10 @@ pcl::octree::OctreePointCloud } } else { - for (std::size_t i = 0; i < input_->size(); i++) { + for (index_t i = 0; i < static_cast(input_->size()); i++) { if (isFinite((*input_)[i])) { // add points to octree - this->addPointIdx(static_cast(i)); + this->addPointIdx(i); } } } @@ -104,7 +105,7 @@ template void pcl::octree::OctreePointCloud:: - addPointFromCloud(const int point_idx_arg, IndicesPtr indices_arg) + addPointFromCloud(const index_t point_idx_arg, IndicesPtr indices_arg) { this->addPointIdx(point_idx_arg); if (indices_arg) @@ -124,7 +125,7 @@ pcl::octree::OctreePointCloud cloud_arg->push_back(point_arg); - this->addPointIdx(static_cast(cloud_arg->size()) - 1); + this->addPointIdx(cloud_arg->size() - 1); } ////////////////////////////////////////////////////////////////////////////////////////////// @@ -143,7 +144,7 @@ pcl::octree::OctreePointCloud cloud_arg->push_back(point_arg); - this->addPointFromCloud(static_cast(cloud_arg->size()) - 1, indices_arg); + this->addPointFromCloud(cloud_arg->size() - 1, indices_arg); } ////////////////////////////////////////////////////////////////////////////////////////////// @@ -175,7 +176,7 @@ template bool pcl::octree::OctreePointCloud:: - isVoxelOccupiedAtPoint(const int& point_idx_arg) const + isVoxelOccupiedAtPoint(const index_t& point_idx_arg) const { // retrieve point from input cloud const PointT& point = (*this->input_)[point_idx_arg]; @@ -233,7 +234,7 @@ template void pcl::octree::OctreePointCloud:: - deleteVoxelAtPoint(const int& point_idx_arg) + deleteVoxelAtPoint(const index_t& point_idx_arg) { // retrieve point from input cloud const PointT& point = (*this->input_)[point_idx_arg]; @@ -247,7 +248,7 @@ template -int +pcl::uindex_t pcl::octree::OctreePointCloud:: getOccupiedVoxelCenters(AlignedPointTVector& voxel_center_list_arg) const { @@ -628,7 +629,7 @@ pcl::octree::OctreePointCloud // add data to new branch OctreeKey new_index_key; - for (const int& leafIndex : leafIndices) { + for (const auto& leafIndex : leafIndices) { const PointT& point_from_index = (*input_)[leafIndex]; // generate key @@ -651,11 +652,11 @@ template void pcl::octree::OctreePointCloud:: - addPointIdx(const int point_idx_arg) + addPointIdx(const index_t point_idx_arg) { OctreeKey key; - assert(point_idx_arg < static_cast(input_->size())); + assert(point_idx_arg < input_->size()); const PointT& point = (*input_)[point_idx_arg]; @@ -699,10 +700,10 @@ template const PointT& pcl::octree::OctreePointCloud:: - getPointByIndex(const unsigned int index_arg) const + getPointByIndex(const index_t index_arg) const { // retrieve point from input cloud - assert(index_arg < static_cast(input_->size())); + assert(index_arg < input_->size()); return ((*this->input_)[index_arg]); } @@ -833,7 +834,7 @@ template bool pcl::octree::OctreePointCloud:: - genOctreeKeyForDataT(const int& data_arg, OctreeKey& key_arg) const + genOctreeKeyForDataT(const index_t& data_arg, OctreeKey& key_arg) const { const PointT temp_point = getPointByIndex(data_arg); @@ -962,13 +963,13 @@ template -int +pcl::uindex_t pcl::octree::OctreePointCloud:: getOccupiedVoxelCentersRecursive(const BranchNode* node_arg, const OctreeKey& key_arg, AlignedPointTVector& voxel_center_list_arg) const { - int voxel_count = 0; + uindex_t voxel_count = 0; // iterate over all children for (unsigned char child_idx = 0; child_idx < 8; child_idx++) { diff --git a/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp b/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp index 51623030f46..0b1a00c6cec 100644 --- a/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp +++ b/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp @@ -153,11 +153,11 @@ pcl::octree::OctreePointCloudAdjacency template void pcl::octree::OctreePointCloudAdjacency:: - addPointIdx(const int pointIdx_arg) + addPointIdx(const index_t pointIdx_arg) { OctreeKey key; - assert(pointIdx_arg < static_cast(this->input_->size())); + assert(pointIdx_arg < this->input_->size()); const PointT& point = (*this->input_)[pointIdx_arg]; if (!pcl::isFinite(point)) diff --git a/octree/include/pcl/octree/impl/octree_search.hpp b/octree/include/pcl/octree/impl/octree_search.hpp index 8269cb98dd9..6f7563bad00 100644 --- a/octree/include/pcl/octree/impl/octree_search.hpp +++ b/octree/include/pcl/octree/impl/octree_search.hpp @@ -71,16 +71,19 @@ OctreePointCloudSearch::voxelSearch( template bool OctreePointCloudSearch::voxelSearch( - const int index, Indices& point_idx_data) + const index_t index, Indices& point_idx_data) { const PointT search_point = this->getPointByIndex(index); return (this->voxelSearch(search_point, point_idx_data)); } template -int +uindex_t OctreePointCloudSearch::nearestKSearch( - const PointT& p_q, int k, Indices& k_indices, std::vector& k_sqr_distances) + const PointT& p_q, + uindex_t k, + Indices& k_indices, + std::vector& k_sqr_distances) { assert(this->leaf_count_ > 0); assert(isFinite(p_q) && @@ -104,23 +107,23 @@ OctreePointCloudSearch::nearestKSearch getKNearestNeighborRecursive( p_q, k, this->root_node_, key, 1, smallest_dist, point_candidates); - unsigned int result_count = static_cast(point_candidates.size()); + index_t result_count = static_cast(point_candidates.size()); k_indices.resize(result_count); k_sqr_distances.resize(result_count); - for (unsigned int i = 0; i < result_count; ++i) { + for (index_t i = 0; i < result_count; ++i) { k_indices[i] = point_candidates[i].point_idx_; k_sqr_distances[i] = point_candidates[i].point_distance_; } - return static_cast(k_indices.size()); + return k_indices.size(); } template -int +uindex_t OctreePointCloudSearch::nearestKSearch( - int index, int k, Indices& k_indices, std::vector& k_sqr_distances) + index_t index, uindex_t k, Indices& k_indices, std::vector& k_sqr_distances) { const PointT search_point = this->getPointByIndex(index); return (nearestKSearch(search_point, k, k_indices, k_sqr_distances)); @@ -129,7 +132,7 @@ OctreePointCloudSearch::nearestKSearch template void OctreePointCloudSearch::approxNearestSearch( - const PointT& p_q, int& result_index, float& sqr_distance) + const PointT& p_q, index_t& result_index, float& sqr_distance) { assert(this->leaf_count_ > 0); assert(isFinite(p_q) && @@ -147,7 +150,7 @@ OctreePointCloudSearch::approxNearestS template void OctreePointCloudSearch::approxNearestSearch( - int query_index, int& result_index, float& sqr_distance) + index_t query_index, index_t& result_index, float& sqr_distance) { const PointT search_point = this->getPointByIndex(query_index); @@ -155,13 +158,13 @@ OctreePointCloudSearch::approxNearestS } template -int +uindex_t OctreePointCloudSearch::radiusSearch( const PointT& p_q, const double radius, Indices& k_indices, std::vector& k_sqr_distances, - unsigned int max_nn) const + uindex_t max_nn) const { assert(isFinite(p_q) && "Invalid (NaN, Inf) point coordinates given to nearestKSearch!"); @@ -180,17 +183,17 @@ OctreePointCloudSearch::radiusSearch( k_sqr_distances, max_nn); - return (static_cast(k_indices.size())); + return k_indices.size(); } template -int +uindex_t OctreePointCloudSearch::radiusSearch( - int index, + index_t index, const double radius, Indices& k_indices, std::vector& k_sqr_distances, - unsigned int max_nn) const + uindex_t max_nn) const { const PointT search_point = this->getPointByIndex(index); @@ -198,7 +201,7 @@ OctreePointCloudSearch::radiusSearch( } template -int +uindex_t OctreePointCloudSearch::boxSearch( const Eigen::Vector3f& min_pt, const Eigen::Vector3f& max_pt, @@ -212,7 +215,7 @@ OctreePointCloudSearch::boxSearch( boxSearchRecursive(min_pt, max_pt, this->root_node_, key, 1, k_indices); - return (static_cast(k_indices.size())); + return k_indices.size(); } template @@ -220,7 +223,7 @@ double OctreePointCloudSearch:: getKNearestNeighborRecursive( const PointT& point, - unsigned int K, + uindex_t K, const BranchNode* node, const OctreeKey& key, unsigned int tree_depth, @@ -295,7 +298,7 @@ OctreePointCloudSearch:: (*child_leaf)->getPointIndices(decoded_point_vector); // Linearly iterate over all decoded (unsorted) points - for (const int& point_index : decoded_point_vector) { + for (const auto& point_index : decoded_point_vector) { const PointT& candidate_point = this->getPointByIndex(point_index); @@ -337,7 +340,7 @@ OctreePointCloudSearch:: unsigned int tree_depth, Indices& k_indices, std::vector& k_sqr_distances, - unsigned int max_nn) const + uindex_t max_nn) const { // get spatial voxel information double voxel_squared_diameter = this->getVoxelSquaredDiameter(tree_depth); @@ -380,7 +383,7 @@ OctreePointCloudSearch:: k_indices, k_sqr_distances, max_nn); - if (max_nn != 0 && k_indices.size() == static_cast(max_nn)) + if (max_nn != 0 && k_indices.size() == max_nn) return; } else { @@ -392,7 +395,7 @@ OctreePointCloudSearch:: (*child_leaf)->getPointIndices(decoded_point_vector); // Linearly iterate over all decoded (unsorted) points - for (const int& index : decoded_point_vector) { + for (const auto& index : decoded_point_vector) { const PointT& candidate_point = this->getPointByIndex(index); // calculate point distance to search point @@ -406,7 +409,7 @@ OctreePointCloudSearch:: k_indices.push_back(index); k_sqr_distances.push_back(squared_dist); - if (max_nn != 0 && k_indices.size() == static_cast(max_nn)) + if (max_nn != 0 && k_indices.size() == max_nn) return; } } @@ -421,7 +424,7 @@ OctreePointCloudSearch:: const BranchNode* node, const OctreeKey& key, unsigned int tree_depth, - int& result_index, + index_t& result_index, float& sqr_distance) { OctreeKey minChildKey; @@ -486,7 +489,7 @@ OctreePointCloudSearch:: (**child_leaf).getPointIndices(decoded_point_vector); // Linearly iterate over all decoded (unsorted) points - for (const int& index : decoded_point_vector) { + for (const auto& index : decoded_point_vector) { const PointT& candidate_point = this->getPointByIndex(index); // calculate point distance to search point @@ -568,7 +571,7 @@ OctreePointCloudSearch::boxSearchRecur (**child_leaf).getPointIndices(decoded_point_vector); // Linearly iterate over all decoded (unsorted) points - for (const int& index : decoded_point_vector) { + for (const auto& index : decoded_point_vector) { const PointT& candidate_point = this->getPointByIndex(index); // check if point falls within search box @@ -587,12 +590,12 @@ OctreePointCloudSearch::boxSearchRecur } template -int +uindex_t OctreePointCloudSearch:: getIntersectedVoxelCenters(Eigen::Vector3f origin, Eigen::Vector3f direction, AlignedPointTVector& voxel_center_list, - int max_voxel_count) const + uindex_t max_voxel_count) const { OctreeKey key; key.x = key.y = key.z = 0; @@ -623,12 +626,12 @@ OctreePointCloudSearch:: } template -int +uindex_t OctreePointCloudSearch:: getIntersectedVoxelIndices(Eigen::Vector3f origin, Eigen::Vector3f direction, Indices& k_indices, - int max_voxel_count) const + uindex_t max_voxel_count) const { OctreeKey key; key.x = key.y = key.z = 0; @@ -657,7 +660,7 @@ OctreePointCloudSearch:: } template -int +uindex_t OctreePointCloudSearch:: getIntersectedVoxelCentersRecursive(double min_x, double min_y, @@ -669,7 +672,7 @@ OctreePointCloudSearch:: const OctreeNode* node, const OctreeKey& key, AlignedPointTVector& voxel_center_list, - int max_voxel_count) const + uindex_t max_voxel_count) const { if (max_x < 0.0 || max_y < 0.0 || max_z < 0.0) return (0); @@ -686,7 +689,7 @@ OctreePointCloudSearch:: } // Voxel intersection count for branches children - int voxel_count = 0; + uindex_t voxel_count = 0; // Voxel mid lines double mid_x = 0.5 * (min_x + max_x); @@ -694,7 +697,7 @@ OctreePointCloudSearch:: double mid_z = 0.5 * (min_z + max_z); // First voxel node ray will intersect - int curr_node = getFirstIntersectedNode(min_x, min_y, min_z, mid_x, mid_y, mid_z); + auto curr_node = getFirstIntersectedNode(min_x, min_y, min_z, mid_x, mid_y, mid_z); // Child index, node and key unsigned char child_idx; @@ -853,7 +856,7 @@ OctreePointCloudSearch:: } template -int +uindex_t OctreePointCloudSearch:: getIntersectedVoxelIndicesRecursive(double min_x, double min_y, @@ -865,7 +868,7 @@ OctreePointCloudSearch:: const OctreeNode* node, const OctreeKey& key, Indices& k_indices, - int max_voxel_count) const + uindex_t max_voxel_count) const { if (max_x < 0.0 || max_y < 0.0 || max_z < 0.0) return (0); @@ -881,7 +884,7 @@ OctreePointCloudSearch:: } // Voxel intersection count for branches children - int voxel_count = 0; + uindex_t voxel_count = 0; // Voxel mid lines double mid_x = 0.5 * (min_x + max_x); @@ -889,7 +892,7 @@ OctreePointCloudSearch:: double mid_z = 0.5 * (min_z + max_z); // First voxel node ray will intersect - int curr_node = getFirstIntersectedNode(min_x, min_y, min_z, mid_x, mid_y, mid_z); + auto curr_node = getFirstIntersectedNode(min_x, min_y, min_z, mid_x, mid_y, mid_z); // Child index, node and key unsigned char child_idx; diff --git a/octree/include/pcl/octree/octree_pointcloud.h b/octree/include/pcl/octree/octree_pointcloud.h index 41e12709cc6..8d7fabc7beb 100644 --- a/octree/include/pcl/octree/octree_pointcloud.h +++ b/octree/include/pcl/octree/octree_pointcloud.h @@ -200,7 +200,7 @@ class OctreePointCloud : public OctreeT { * setInputCloud) */ void - addPointFromCloud(const int point_idx_arg, IndicesPtr indices_arg); + addPointFromCloud(index_t point_idx_arg, IndicesPtr indices_arg); /** \brief Add point simultaneously to octree and input point cloud. * \param[in] point_arg point to be added @@ -258,14 +258,14 @@ class OctreePointCloud : public OctreeT { * \return "true" if voxel exist; "false" otherwise */ bool - isVoxelOccupiedAtPoint(const int& point_idx_arg) const; + isVoxelOccupiedAtPoint(const index_t& point_idx_arg) const; /** \brief Get a PointT vector of centers of all occupied voxels. * \param[out] voxel_center_list_arg results are written to this vector of PointT * elements * \return number of occupied voxels */ - int + uindex_t getOccupiedVoxelCenters(AlignedPointTVector& voxel_center_list_arg) const; /** \brief Get a PointT vector of centers of voxels intersected by a line segment. @@ -295,7 +295,7 @@ class OctreePointCloud : public OctreeT { * \param[in] point_idx_arg index of point addressing the voxel to be deleted. */ void - deleteVoxelAtPoint(const int& point_idx_arg); + deleteVoxelAtPoint(const index_t& point_idx_arg); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Bounding box methods @@ -428,7 +428,7 @@ class OctreePointCloud : public OctreeT { * \a setInputCloud to be added */ virtual void - addPointIdx(const int point_idx_arg); + addPointIdx(index_t point_idx_arg); /** \brief Add point at index from input pointcloud dataset to octree * \param[in] leaf_node to be expanded @@ -448,7 +448,7 @@ class OctreePointCloud : public OctreeT { * \return PointT from input pointcloud dataset */ const PointT& - getPointByIndex(const unsigned int index_arg) const; + getPointByIndex(index_t index_arg) const; /** \brief Find octree leaf node at a given point * \param[in] point_arg query point @@ -520,7 +520,7 @@ class OctreePointCloud : public OctreeT { * are assignable */ virtual bool - genOctreeKeyForDataT(const int& data_arg, OctreeKey& key_arg) const; + genOctreeKeyForDataT(const index_t& data_arg, OctreeKey& key_arg) const; /** \brief Generate a point at center of leaf node voxel * \param[in] key_arg octree key addressing a leaf node. @@ -560,7 +560,7 @@ class OctreePointCloud : public OctreeT { * elements * \return number of voxels found */ - int + uindex_t getOccupiedVoxelCentersRecursive(const BranchNode* node_arg, const OctreeKey& key_arg, AlignedPointTVector& voxel_center_list_arg) const; diff --git a/octree/include/pcl/octree/octree_pointcloud_adjacency.h b/octree/include/pcl/octree/octree_pointcloud_adjacency.h index bc9c55cb26c..8b93c9b71d3 100644 --- a/octree/include/pcl/octree/octree_pointcloud_adjacency.h +++ b/octree/include/pcl/octree/octree_pointcloud_adjacency.h @@ -195,7 +195,7 @@ class OctreePointCloudAdjacency * \note This virtual implementation allows the use of a transform function to compute * keys. */ void - addPointIdx(const int point_idx_arg) override; + addPointIdx(index_t point_idx_arg) override; /** \brief Fills in the neighbors fields for new voxels. * diff --git a/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h b/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h index 16f257cdf97..f79f53e0d81 100644 --- a/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h +++ b/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h @@ -170,7 +170,7 @@ class OctreePointCloudAdjacencyContainer : public OctreeContainerBase { /** \brief Sets the number of points contributing to this leaf */ void - setPointCounter(int points_arg) + setPointCounter(uindex_t points_arg) { num_points_ = points_arg; } @@ -218,7 +218,7 @@ class OctreePointCloudAdjacencyContainer : public OctreeContainerBase { } private: - int num_points_; + uindex_t num_points_; NeighborListT neighbors_; DataT data_; }; diff --git a/octree/include/pcl/octree/octree_pointcloud_density.h b/octree/include/pcl/octree/octree_pointcloud_density.h index 19e97d045d1..61545019577 100644 --- a/octree/include/pcl/octree/octree_pointcloud_density.h +++ b/octree/include/pcl/octree/octree_pointcloud_density.h @@ -76,11 +76,7 @@ class OctreePointCloudDensityContainer : public OctreeContainerBase { /** \brief Read input data. Only an internal counter is increased. */ - void - addPointIndex(int) - { - point_counter_++; - } + void addPointIndex(index_t) { point_counter_++; } /** \brief Return point counter. * \return Amount of points @@ -99,7 +95,7 @@ class OctreePointCloudDensityContainer : public OctreeContainerBase { } private: - unsigned int point_counter_; + uindex_t point_counter_; }; /** \brief @b Octree pointcloud density class @@ -136,7 +132,7 @@ class OctreePointCloudDensity unsigned int getVoxelDensityAtPoint(const PointT& point_arg) const { - unsigned int point_count = 0; + uindex_t point_count = 0; OctreePointCloudDensityContainer* leaf = this->findLeafAtPoint(point_arg); diff --git a/octree/include/pcl/octree/octree_pointcloud_voxelcentroid.h b/octree/include/pcl/octree/octree_pointcloud_voxelcentroid.h index 1207db8ec99..4c8973f9019 100644 --- a/octree/include/pcl/octree/octree_pointcloud_voxelcentroid.h +++ b/octree/include/pcl/octree/octree_pointcloud_voxelcentroid.h @@ -114,7 +114,7 @@ class OctreePointCloudVoxelCentroidContainer : public OctreeContainerBase { } private: - unsigned int point_counter_; + uindex_t point_counter_; PointT point_sum_; }; @@ -156,11 +156,11 @@ class OctreePointCloudVoxelCentroid * \param pointIdx_arg */ void - addPointIdx(const int pointIdx_arg) override + addPointIdx(const index_t pointIdx_arg) override { OctreeKey key; - assert(pointIdx_arg < static_cast(this->input_->size())); + assert(pointIdx_arg < this->input_->size()); const PointT& point = (*this->input_)[pointIdx_arg]; @@ -190,7 +190,8 @@ class OctreePointCloudVoxelCentroid * \return "true" if voxel is found; "false" otherwise */ inline bool - getVoxelCentroidAtPoint(const int& point_idx_arg, PointT& voxel_centroid_arg) const + getVoxelCentroidAtPoint(const index_t& point_idx_arg, + PointT& voxel_centroid_arg) const { // get centroid at point return (this->getVoxelCentroidAtPoint((*this->input_)[point_idx_arg], @@ -202,7 +203,7 @@ class OctreePointCloudVoxelCentroid * elements * \return number of occupied voxels */ - std::size_t + uindex_t getVoxelCentroids( typename OctreePointCloud:: AlignedPointTVector& voxel_centroid_list_arg) const; diff --git a/octree/include/pcl/octree/octree_search.h b/octree/include/pcl/octree/octree_search.h index 6ea74d9e643..df5dffaca9d 100644 --- a/octree/include/pcl/octree/octree_search.h +++ b/octree/include/pcl/octree/octree_search.h @@ -100,7 +100,7 @@ class OctreePointCloudSearch * \return "true" if leaf node exist; "false" otherwise */ bool - voxelSearch(const int index, Indices& point_idx_data); + voxelSearch(const index_t index, Indices& point_idx_data); /** \brief Search for k-nearest neighbors at the query point. * \param[in] cloud the point cloud data @@ -112,10 +112,10 @@ class OctreePointCloudSearch * points (must be resized to \a k a priori!) * \return number of neighbors found */ - inline int + inline uindex_t nearestKSearch(const PointCloud& cloud, - int index, - int k, + index_t index, + uindex_t k, Indices& k_indices, std::vector& k_sqr_distances) { @@ -131,9 +131,9 @@ class OctreePointCloudSearch * points (must be resized to k a priori!) * \return number of neighbors found */ - int + uindex_t nearestKSearch(const PointT& p_q, - int k, + uindex_t k, Indices& k_indices, std::vector& k_sqr_distances); @@ -148,9 +148,9 @@ class OctreePointCloudSearch * points (must be resized to \a k a priori!) * \return number of neighbors found */ - int - nearestKSearch(int index, - int k, + uindex_t + nearestKSearch(index_t index, + uindex_t k, Indices& k_indices, std::vector& k_sqr_distances); @@ -163,8 +163,8 @@ class OctreePointCloudSearch */ inline void approxNearestSearch(const PointCloud& cloud, - int query_index, - int& result_index, + index_t query_index, + index_t& result_index, float& sqr_distance) { return (approxNearestSearch(cloud[query_index], result_index, sqr_distance)); @@ -176,7 +176,7 @@ class OctreePointCloudSearch * \param[out] sqr_distance the resultant squared distance to the neighboring point */ void - approxNearestSearch(const PointT& p_q, int& result_index, float& sqr_distance); + approxNearestSearch(const PointT& p_q, index_t& result_index, float& sqr_distance); /** \brief Search for approx. nearest neighbor at the query point. * \param[in] query_index index representing the query point in the dataset given by @@ -187,7 +187,7 @@ class OctreePointCloudSearch * \return number of neighbors found */ void - approxNearestSearch(int query_index, int& result_index, float& sqr_distance); + approxNearestSearch(index_t query_index, index_t& result_index, float& sqr_distance); /** \brief Search for all neighbors of query point that are within a given radius. * \param[in] cloud the point cloud data @@ -199,13 +199,13 @@ class OctreePointCloudSearch * \param[in] max_nn if given, bounds the maximum returned neighbors to this value * \return number of neighbors found in radius */ - int + uindex_t radiusSearch(const PointCloud& cloud, - int index, + index_t index, double radius, Indices& k_indices, std::vector& k_sqr_distances, - unsigned int max_nn = 0) + index_t max_nn = 0) { return (radiusSearch(cloud[index], radius, k_indices, k_sqr_distances, max_nn)); } @@ -219,12 +219,12 @@ class OctreePointCloudSearch * \param[in] max_nn if given, bounds the maximum returned neighbors to this value * \return number of neighbors found in radius */ - int + uindex_t radiusSearch(const PointT& p_q, const double radius, Indices& k_indices, std::vector& k_sqr_distances, - unsigned int max_nn = 0) const; + uindex_t max_nn = 0) const; /** \brief Search for all neighbors of query point that are within a given radius. * \param[in] index index representing the query point in the dataset given by \a @@ -237,12 +237,12 @@ class OctreePointCloudSearch * \param[in] max_nn if given, bounds the maximum returned neighbors to this value * \return number of neighbors found in radius */ - int - radiusSearch(int index, + uindex_t + radiusSearch(index_t index, const double radius, Indices& k_indices, std::vector& k_sqr_distances, - unsigned int max_nn = 0) const; + uindex_t max_nn = 0) const; /** \brief Get a PointT vector of centers of all voxels that intersected by a ray * (origin, direction). @@ -253,11 +253,11 @@ class OctreePointCloudSearch * disable) * \return number of intersected voxels */ - int + uindex_t getIntersectedVoxelCenters(Eigen::Vector3f origin, Eigen::Vector3f direction, AlignedPointTVector& voxel_center_list, - int max_voxel_count = 0) const; + uindex_t max_voxel_count = 0) const; /** \brief Get indices of all voxels that are intersected by a ray (origin, * direction). @@ -267,11 +267,11 @@ class OctreePointCloudSearch * disable) * \return number of intersected voxels */ - int + uindex_t getIntersectedVoxelIndices(Eigen::Vector3f origin, Eigen::Vector3f direction, Indices& k_indices, - int max_voxel_count = 0) const; + uindex_t max_voxel_count = 0) const; /** \brief Search for points within rectangular search area * Points exactly on the edges of the search rectangle are included. @@ -280,7 +280,7 @@ class OctreePointCloudSearch * \param[out] k_indices the resultant point indices * \return number of points found within search area */ - int + uindex_t boxSearch(const Eigen::Vector3f& min_pt, const Eigen::Vector3f& max_pt, Indices& k_indices) const; @@ -341,7 +341,7 @@ class OctreePointCloudSearch * \param[in] point_idx index for a dataset point given by \a setInputCloud * \param[in] point_distance distance of query point to voxel center */ - prioPointQueueEntry(unsigned int& point_idx, float point_distance) + prioPointQueueEntry(index_t point_idx, float point_distance) : point_idx_(point_idx), point_distance_(point_distance) {} @@ -355,7 +355,7 @@ class OctreePointCloudSearch } /** \brief Index representing a point in the dataset given by \a setInputCloud. */ - int point_idx_; + index_t point_idx_; /** \brief Distance to query point. */ float point_distance_; @@ -391,7 +391,7 @@ class OctreePointCloudSearch unsigned int tree_depth, Indices& k_indices, std::vector& k_sqr_distances, - unsigned int max_nn) const; + uindex_t max_nn) const; /** \brief Recursive search method that explores the octree and finds the K nearest * neighbors @@ -407,7 +407,7 @@ class OctreePointCloudSearch double getKNearestNeighborRecursive( const PointT& point, - unsigned int K, + uindex_t K, const BranchNode* node, const OctreeKey& key, unsigned int tree_depth, @@ -428,7 +428,7 @@ class OctreePointCloudSearch const BranchNode* node, const OctreeKey& key, unsigned int tree_depth, - int& result_index, + index_t& result_index, float& sqr_distance); /** \brief Recursively search the tree for all intersected leaf nodes and return a @@ -449,7 +449,7 @@ class OctreePointCloudSearch * disable) * \return number of voxels found */ - int + uindex_t getIntersectedVoxelCentersRecursive(double min_x, double min_y, double min_z, @@ -460,7 +460,7 @@ class OctreePointCloudSearch const OctreeNode* node, const OctreeKey& key, AlignedPointTVector& voxel_center_list, - int max_voxel_count) const; + uindex_t max_voxel_count) const; /** \brief Recursive search method that explores the octree and finds points within a * rectangular search area @@ -496,7 +496,7 @@ class OctreePointCloudSearch * disable) * \return number of voxels found */ - int + uindex_t getIntersectedVoxelIndicesRecursive(double min_x, double min_y, double min_z, @@ -507,7 +507,7 @@ class OctreePointCloudSearch const OctreeNode* node, const OctreeKey& key, Indices& k_indices, - int max_voxel_count) const; + uindex_t max_voxel_count) const; /** \brief Initialize raytracing algorithm * \param origin From c195686fef0995d93b42fce983faeccd51c1ddb4 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Tue, 25 Aug 2020 04:45:34 +0900 Subject: [PATCH 03/12] Second batch of changes detected via io --- io/include/pcl/compression/color_coding.h | 4 ++-- .../impl/octree_pointcloud_compression.hpp | 2 +- io/include/pcl/compression/point_coding.h | 2 +- octree/include/pcl/octree/octree_container.h | 16 ++++++++-------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/io/include/pcl/compression/color_coding.h b/io/include/pcl/compression/color_coding.h index b4b9e6de5e5..af0e6414df5 100644 --- a/io/include/pcl/compression/color_coding.h +++ b/io/include/pcl/compression/color_coding.h @@ -155,7 +155,7 @@ class ColorCoding * \param inputCloud_arg input point cloud * */ void - encodeAverageOfPoints (const typename std::vector& indexVector_arg, unsigned char rgba_offset_arg, PointCloudConstPtr inputCloud_arg) + encodeAverageOfPoints (const Indices& indexVector_arg, unsigned char rgba_offset_arg, PointCloudConstPtr inputCloud_arg) { unsigned int avgRed = 0; unsigned int avgGreen = 0; @@ -202,7 +202,7 @@ class ColorCoding * \param inputCloud_arg input point cloud * */ void - encodePoints (const typename std::vector& indexVector_arg, unsigned char rgba_offset_arg, PointCloudConstPtr inputCloud_arg) + encodePoints (const Indices& indexVector_arg, unsigned char rgba_offset_arg, PointCloudConstPtr inputCloud_arg) { unsigned int avgRed; unsigned int avgGreen; diff --git a/io/include/pcl/compression/impl/octree_pointcloud_compression.hpp b/io/include/pcl/compression/impl/octree_pointcloud_compression.hpp index e28e754b306..098f579fc25 100644 --- a/io/include/pcl/compression/impl/octree_pointcloud_compression.hpp +++ b/io/include/pcl/compression/impl/octree_pointcloud_compression.hpp @@ -473,7 +473,7 @@ namespace pcl LeafT &leaf_arg, const OctreeKey & key_arg) { // reference to point indices vector stored within octree leaf - const std::vector& leafIdx = leaf_arg.getPointIndicesVector(); + const auto& leafIdx = leaf_arg.getPointIndicesVector(); if (!do_voxel_grid_enDecoding_) { diff --git a/io/include/pcl/compression/point_coding.h b/io/include/pcl/compression/point_coding.h index a23a8678ab1..d10eb23c44c 100644 --- a/io/include/pcl/compression/point_coding.h +++ b/io/include/pcl/compression/point_coding.h @@ -126,7 +126,7 @@ class PointCoding * \param inputCloud_arg input point cloud */ void - encodePoints (const typename std::vector& indexVector_arg, const double* referencePoint_arg, + encodePoints (const Indices& indexVector_arg, const double* referencePoint_arg, PointCloudConstPtr inputCloud_arg) { std::size_t len = indexVector_arg.size (); diff --git a/octree/include/pcl/octree/octree_container.h b/octree/include/pcl/octree/octree_container.h index 4452f0ca04a..a3867aee2cd 100644 --- a/octree/include/pcl/octree/octree_container.h +++ b/octree/include/pcl/octree/octree_container.h @@ -90,14 +90,14 @@ class OctreeContainerBase { * indices. */ void - addPointIndex(const int&) + addPointIndex(const index_t&) {} /** \brief Empty getPointIndex implementation as this leaf node does not store any * point indices. */ void - getPointIndex(int&) const + getPointIndex(index_t&) const {} /** \brief Empty getPointIndices implementation as this leaf node does not store any @@ -148,7 +148,7 @@ class OctreeContainerEmpty : public OctreeContainerBase { /** \brief Empty getPointIndex implementation as this leaf node does not store any * point indices. */ - int + index_t getPointIndex() const { assert("getPointIndex: undefined point index"); @@ -197,7 +197,7 @@ class OctreeContainerPointIndex : public OctreeContainerBase { * \param[in] data_arg index to be stored within leaf node. */ void - addPointIndex(int data_arg) + addPointIndex(index_t data_arg) { data_ = data_arg; } @@ -206,7 +206,7 @@ class OctreeContainerPointIndex : public OctreeContainerBase { * point index * \return index stored within container. */ - int + index_t getPointIndex() const { return data_; @@ -242,7 +242,7 @@ class OctreeContainerPointIndex : public OctreeContainerBase { protected: /** \brief Point index stored in octree. */ - int data_; + index_t data_; }; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -276,7 +276,7 @@ class OctreeContainerPointIndices : public OctreeContainerBase { * \param[in] data_arg index to be stored within leaf node. */ void - addPointIndex(int data_arg) + addPointIndex(index_t data_arg) { leafDataTVector_.push_back(data_arg); } @@ -285,7 +285,7 @@ class OctreeContainerPointIndices : public OctreeContainerBase { * point indices. * \return index stored within container. */ - int + index_t getPointIndex() const { return leafDataTVector_.back(); From 730d376e0f3317a68a410be0b0e7527b312fd853 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Sat, 19 Sep 2020 03:15:10 +0900 Subject: [PATCH 04/12] Get parts of code compiling --- .../pcl/octree/impl/octree2buf_base.hpp | 47 +++++++++--------- .../include/pcl/octree/impl/octree_base.hpp | 44 ++++++++--------- .../pcl/octree/impl/octree_iterator.hpp | 23 +++++---- .../pcl/octree/impl/octree_pointcloud.hpp | 4 +- .../impl/octree_pointcloud_adjacency.hpp | 22 +++------ .../impl/octree_pointcloud_voxelcentroid.hpp | 2 +- octree/include/pcl/octree/octree2buf_base.h | 42 ++++++++-------- octree/include/pcl/octree/octree_base.h | 44 ++++++++--------- octree/include/pcl/octree/octree_container.h | 14 +++--- octree/include/pcl/octree/octree_iterator.h | 49 +++++++++---------- octree/include/pcl/octree/octree_key.h | 10 ++-- octree/include/pcl/octree/octree_pointcloud.h | 2 +- octree/src/octree_inst.cpp | 4 +- 13 files changed, 147 insertions(+), 160 deletions(-) diff --git a/octree/include/pcl/octree/impl/octree2buf_base.hpp b/octree/include/pcl/octree/impl/octree2buf_base.hpp index edaea812171..477233e8629 100644 --- a/octree/include/pcl/octree/impl/octree2buf_base.hpp +++ b/octree/include/pcl/octree/impl/octree2buf_base.hpp @@ -67,17 +67,17 @@ Octree2BufBase::~Octree2BufBase() template void Octree2BufBase::setMaxVoxelIndex( - unsigned int max_voxel_index_arg) + uindex_t max_voxel_index_arg) { - unsigned int treeDepth; + uindex_t treeDepth; assert(max_voxel_index_arg > 0); // tree depth == amount of bits of maxVoxels - treeDepth = std::max( - (std::min(static_cast(OctreeKey::maxDepth), - static_cast(std::ceil(std::log2(max_voxel_index_arg))))), - static_cast(0)); + treeDepth = + std::max(std::min(OctreeKey::maxDepth, + std::ceil(std::log2(max_voxel_index_arg))), + 0); // define depthMask_ by setting a single bit to 1 at bit position == tree depth depth_mask_ = (1 << (treeDepth - 1)); @@ -86,7 +86,7 @@ Octree2BufBase::setMaxVoxelIndex( ////////////////////////////////////////////////////////////////////////////////////////////// template void -Octree2BufBase::setTreeDepth(unsigned int depth_arg) +Octree2BufBase::setTreeDepth(uindex_t depth_arg) { assert(depth_arg > 0); @@ -103,9 +103,9 @@ Octree2BufBase::setTreeDepth(unsigned int dept ////////////////////////////////////////////////////////////////////////////////////////////// template LeafContainerT* -Octree2BufBase::findLeaf(unsigned int idx_x_arg, - unsigned int idx_y_arg, - unsigned int idx_z_arg) +Octree2BufBase::findLeaf(uindex_t idx_x_arg, + uindex_t idx_y_arg, + uindex_t idx_z_arg) { // generate key OctreeKey key(idx_x_arg, idx_y_arg, idx_z_arg); @@ -117,9 +117,9 @@ Octree2BufBase::findLeaf(unsigned int idx_x_ar ////////////////////////////////////////////////////////////////////////////////////////////// template LeafContainerT* -Octree2BufBase::createLeaf(unsigned int idx_x_arg, - unsigned int idx_y_arg, - unsigned int idx_z_arg) +Octree2BufBase::createLeaf(uindex_t idx_x_arg, + uindex_t idx_y_arg, + uindex_t idx_z_arg) { // generate key OctreeKey key(idx_x_arg, idx_y_arg, idx_z_arg); @@ -131,8 +131,9 @@ Octree2BufBase::createLeaf(unsigned int idx_x_ ////////////////////////////////////////////////////////////////////////////////////////////// template bool -Octree2BufBase::existLeaf( - unsigned int idx_x_arg, unsigned int idx_y_arg, unsigned int idx_z_arg) const +Octree2BufBase::existLeaf(uindex_t idx_x_arg, + uindex_t idx_y_arg, + uindex_t idx_z_arg) const { // generate key OctreeKey key(idx_x_arg, idx_y_arg, idx_z_arg); @@ -144,9 +145,9 @@ Octree2BufBase::existLeaf( ////////////////////////////////////////////////////////////////////////////////////////////// template void -Octree2BufBase::removeLeaf(unsigned int idx_x_arg, - unsigned int idx_y_arg, - unsigned int idx_z_arg) +Octree2BufBase::removeLeaf(uindex_t idx_x_arg, + uindex_t idx_y_arg, + uindex_t idx_z_arg) { // generate key OctreeKey key(idx_x_arg, idx_y_arg, idx_z_arg); @@ -352,10 +353,10 @@ Octree2BufBase::serializeNewLeafs( ////////////////////////////////////////////////////////////////////////////////////////////// template -unsigned int +uindex_t Octree2BufBase::createLeafRecursive( const OctreeKey& key_arg, - unsigned int depth_mask_arg, + uindex_t depth_mask_arg, BranchNode* branch_arg, LeafNode*& return_leaf_arg, BranchNode*& parent_of_leaf_arg, @@ -465,7 +466,7 @@ template void Octree2BufBase::findLeafRecursive( const OctreeKey& key_arg, - unsigned int depth_mask_arg, + uindex_t depth_mask_arg, BranchNode* branch_arg, LeafContainerT*& result_arg) const { @@ -500,7 +501,7 @@ Octree2BufBase::findLeafRecursive( template bool Octree2BufBase::deleteLeafRecursive( - const OctreeKey& key_arg, unsigned int depth_mask_arg, BranchNode* branch_arg) + const OctreeKey& key_arg, uindex_t depth_mask_arg, BranchNode* branch_arg) { // index to branch child unsigned char child_idx; @@ -642,7 +643,7 @@ template void Octree2BufBase::deserializeTreeRecursive( BranchNode* branch_arg, - unsigned int depth_mask_arg, + uindex_t depth_mask_arg, OctreeKey& key_arg, typename std::vector::const_iterator& binaryTreeIT_arg, typename std::vector::const_iterator& binaryTreeIT_End_arg, diff --git a/octree/include/pcl/octree/impl/octree_base.hpp b/octree/include/pcl/octree/impl/octree_base.hpp index 70ca1974d07..afd9d3c8e13 100644 --- a/octree/include/pcl/octree/impl/octree_base.hpp +++ b/octree/include/pcl/octree/impl/octree_base.hpp @@ -67,16 +67,16 @@ OctreeBase::~OctreeBase() template void OctreeBase::setMaxVoxelIndex( - unsigned int max_voxel_index_arg) + uindex_t max_voxel_index_arg) { - unsigned int tree_depth; + uindex_t tree_depth; assert(max_voxel_index_arg > 0); // tree depth == bitlength of maxVoxels tree_depth = - std::min(static_cast(OctreeKey::maxDepth), - static_cast(std::ceil(std::log2(max_voxel_index_arg)))); + std::min(static_cast(OctreeKey::maxDepth), + static_cast(std::ceil(std::log2(max_voxel_index_arg)))); // define depthMask_ by setting a single bit to 1 at bit position == tree depth depth_mask_ = (1 << (tree_depth - 1)); @@ -85,7 +85,7 @@ OctreeBase::setMaxVoxelIndex( ////////////////////////////////////////////////////////////////////////////////////////////// template void -OctreeBase::setTreeDepth(unsigned int depth_arg) +OctreeBase::setTreeDepth(uindex_t depth_arg) { assert(depth_arg > 0); @@ -102,9 +102,9 @@ OctreeBase::setTreeDepth(unsigned int depth_ar ////////////////////////////////////////////////////////////////////////////////////////////// template LeafContainerT* -OctreeBase::findLeaf(unsigned int idx_x_arg, - unsigned int idx_y_arg, - unsigned int idx_z_arg) +OctreeBase::findLeaf(uindex_t idx_x_arg, + uindex_t idx_y_arg, + uindex_t idx_z_arg) { // generate key OctreeKey key(idx_x_arg, idx_y_arg, idx_z_arg); @@ -116,9 +116,9 @@ OctreeBase::findLeaf(unsigned int idx_x_arg, ////////////////////////////////////////////////////////////////////////////////////////////// template LeafContainerT* -OctreeBase::createLeaf(unsigned int idx_x_arg, - unsigned int idx_y_arg, - unsigned int idx_z_arg) +OctreeBase::createLeaf(uindex_t idx_x_arg, + uindex_t idx_y_arg, + uindex_t idx_z_arg) { // generate key OctreeKey key(idx_x_arg, idx_y_arg, idx_z_arg); @@ -130,9 +130,9 @@ OctreeBase::createLeaf(unsigned int idx_x_arg, ////////////////////////////////////////////////////////////////////////////////////////////// template bool -OctreeBase::existLeaf(unsigned int idx_x_arg, - unsigned int idx_y_arg, - unsigned int idx_z_arg) const +OctreeBase::existLeaf(uindex_t idx_x_arg, + uindex_t idx_y_arg, + uindex_t idx_z_arg) const { // generate key OctreeKey key(idx_x_arg, idx_y_arg, idx_z_arg); @@ -144,9 +144,9 @@ OctreeBase::existLeaf(unsigned int idx_x_arg, ////////////////////////////////////////////////////////////////////////////////////////////// template void -OctreeBase::removeLeaf(unsigned int idx_x_arg, - unsigned int idx_y_arg, - unsigned int idx_z_arg) +OctreeBase::removeLeaf(uindex_t idx_x_arg, + uindex_t idx_y_arg, + uindex_t idx_z_arg) { // generate key OctreeKey key(idx_x_arg, idx_y_arg, idx_z_arg); @@ -281,10 +281,10 @@ OctreeBase::deserializeTree( ////////////////////////////////////////////////////////////////////////////////////////////// template -unsigned int +uindex_t OctreeBase::createLeafRecursive( const OctreeKey& key_arg, - unsigned int depth_mask_arg, + uindex_t depth_mask_arg, BranchNode* branch_arg, LeafNode*& return_leaf_arg, BranchNode*& parent_of_leaf_arg) @@ -344,7 +344,7 @@ template void OctreeBase::findLeafRecursive( const OctreeKey& key_arg, - unsigned int depth_mask_arg, + uindex_t depth_mask_arg, BranchNode* branch_arg, LeafContainerT*& result_arg) const { @@ -381,7 +381,7 @@ OctreeBase::findLeafRecursive( template bool OctreeBase::deleteLeafRecursive( - const OctreeKey& key_arg, unsigned int depth_mask_arg, BranchNode* branch_arg) + const OctreeKey& key_arg, uindex_t depth_mask_arg, BranchNode* branch_arg) { // index to branch child unsigned char child_idx; @@ -491,7 +491,7 @@ template void OctreeBase::deserializeTreeRecursive( BranchNode* branch_arg, - unsigned int depth_mask_arg, + uindex_t depth_mask_arg, OctreeKey& key_arg, typename std::vector::const_iterator& binary_tree_input_it_arg, typename std::vector::const_iterator& binary_tree_input_it_end_arg, diff --git a/octree/include/pcl/octree/impl/octree_iterator.hpp b/octree/include/pcl/octree/impl/octree_iterator.hpp index 76e33fab632..bb0d7719e7a 100644 --- a/octree/include/pcl/octree/impl/octree_iterator.hpp +++ b/octree/include/pcl/octree/impl/octree_iterator.hpp @@ -45,7 +45,7 @@ namespace pcl { namespace octree { ////////////////////////////////////////////////////////////////////////////////////////////// template -OctreeDepthFirstIterator::OctreeDepthFirstIterator(unsigned int max_depth_arg) +OctreeDepthFirstIterator::OctreeDepthFirstIterator(uindex_t max_depth_arg) : OctreeIteratorBase(max_depth_arg), stack_() { // initialize iterator @@ -55,7 +55,7 @@ OctreeDepthFirstIterator::OctreeDepthFirstIterator(unsigned int max_dep ////////////////////////////////////////////////////////////////////////////////////////////// template OctreeDepthFirstIterator::OctreeDepthFirstIterator(OctreeT* octree_arg, - unsigned int max_depth_arg) + uindex_t max_depth_arg) : OctreeIteratorBase(octree_arg, max_depth_arg), stack_() { // initialize iterator @@ -163,8 +163,7 @@ OctreeDepthFirstIterator::operator++() ////////////////////////////////////////////////////////////////////////////////////////////// template -OctreeBreadthFirstIterator::OctreeBreadthFirstIterator( - unsigned int max_depth_arg) +OctreeBreadthFirstIterator::OctreeBreadthFirstIterator(uindex_t max_depth_arg) : OctreeIteratorBase(max_depth_arg), FIFO_() { OctreeIteratorBase::reset(); @@ -175,8 +174,8 @@ OctreeBreadthFirstIterator::OctreeBreadthFirstIterator( ////////////////////////////////////////////////////////////////////////////////////////////// template -OctreeBreadthFirstIterator::OctreeBreadthFirstIterator( - OctreeT* octree_arg, unsigned int max_depth_arg) +OctreeBreadthFirstIterator::OctreeBreadthFirstIterator(OctreeT* octree_arg, + uindex_t max_depth_arg) : OctreeIteratorBase(octree_arg, max_depth_arg), FIFO_() { OctreeIteratorBase::reset(); @@ -264,8 +263,8 @@ OctreeFixedDepthIterator::OctreeFixedDepthIterator() ////////////////////////////////////////////////////////////////////////////////////////////// template -OctreeFixedDepthIterator::OctreeFixedDepthIterator( - OctreeT* octree_arg, unsigned int fixed_depth_arg) +OctreeFixedDepthIterator::OctreeFixedDepthIterator(OctreeT* octree_arg, + uindex_t fixed_depth_arg) : OctreeBreadthFirstIterator(octree_arg, fixed_depth_arg) , fixed_depth_(fixed_depth_arg) { @@ -275,7 +274,7 @@ OctreeFixedDepthIterator::OctreeFixedDepthIterator( ////////////////////////////////////////////////////////////////////////////////////////////// template void -OctreeFixedDepthIterator::reset(unsigned int fixed_depth_arg) +OctreeFixedDepthIterator::reset(uindex_t fixed_depth_arg) { // Set the desired depth to walk through fixed_depth_ = fixed_depth_arg; @@ -315,7 +314,7 @@ OctreeFixedDepthIterator::reset(unsigned int fixed_depth_arg) ////////////////////////////////////////////////////////////////////////////////////////////// template OctreeLeafNodeBreadthFirstIterator::OctreeLeafNodeBreadthFirstIterator( - unsigned int max_depth_arg) + uindex_t max_depth_arg) : OctreeBreadthFirstIterator(max_depth_arg) { reset(); @@ -324,7 +323,7 @@ OctreeLeafNodeBreadthFirstIterator::OctreeLeafNodeBreadthFirstIterator( ////////////////////////////////////////////////////////////////////////////////////////////// template OctreeLeafNodeBreadthFirstIterator::OctreeLeafNodeBreadthFirstIterator( - OctreeT* octree_arg, unsigned int max_depth_arg) + OctreeT* octree_arg, uindex_t max_depth_arg) : OctreeBreadthFirstIterator(octree_arg, max_depth_arg) { reset(); @@ -334,7 +333,7 @@ OctreeLeafNodeBreadthFirstIterator::OctreeLeafNodeBreadthFirstIterator( template OctreeLeafNodeBreadthFirstIterator::OctreeLeafNodeBreadthFirstIterator( OctreeT* octree_arg, - unsigned int max_depth_arg, + uindex_t max_depth_arg, IteratorState* current_state, const std::deque& fifo) : OctreeBreadthFirstIterator(octree_arg, max_depth_arg, current_state, fifo) diff --git a/octree/include/pcl/octree/impl/octree_pointcloud.hpp b/octree/include/pcl/octree/impl/octree_pointcloud.hpp index c467417f6dc..bf3e5a5dc75 100644 --- a/octree/include/pcl/octree/impl/octree_pointcloud.hpp +++ b/octree/include/pcl/octree/impl/octree_pointcloud.hpp @@ -265,7 +265,7 @@ template -int +pcl::index_t pcl::octree::OctreePointCloud:: getApproxIntersectedVoxelCentersBySegment(const Eigen::Vector3f& origin, const Eigen::Vector3f& end, @@ -320,7 +320,7 @@ pcl::octree::OctreePointCloud voxel_center_list.push_back(center); } - return (static_cast(voxel_center_list.size())); + return (static_cast(voxel_center_list.size())); } ////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp b/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp index 0b1a00c6cec..3bcaf1ce147 100644 --- a/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp +++ b/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp @@ -127,12 +127,9 @@ pcl::octree::OctreePointCloudAdjacency if (pcl::isFinite(temp)) // Make sure transformed point is finite - if it is not, it // gets default key { - key_arg.x = - static_cast((temp.x - this->min_x_) / this->resolution_); - key_arg.y = - static_cast((temp.y - this->min_y_) / this->resolution_); - key_arg.z = - static_cast((temp.z - this->min_z_) / this->resolution_); + key_arg.x = static_cast((temp.x - this->min_x_) / this->resolution_); + key_arg.y = static_cast((temp.y - this->min_y_) / this->resolution_); + key_arg.z = static_cast((temp.z - this->min_z_) / this->resolution_); } else { key_arg = OctreeKey(); @@ -140,12 +137,9 @@ pcl::octree::OctreePointCloudAdjacency } else { // calculate integer key for point coordinates - key_arg.x = - static_cast((point_arg.x - this->min_x_) / this->resolution_); - key_arg.y = - static_cast((point_arg.y - this->min_y_) / this->resolution_); - key_arg.z = - static_cast((point_arg.z - this->min_z_) / this->resolution_); + key_arg.x = static_cast((point_arg.x - this->min_x_) / this->resolution_); + key_arg.y = static_cast((point_arg.y - this->min_y_) / this->resolution_); + key_arg.z = static_cast((point_arg.z - this->min_z_) / this->resolution_); } } @@ -294,13 +288,13 @@ pcl::octree::OctreePointCloudAdjacency direction.normalize(); float precision = 1.0f; const float step_size = static_cast(resolution_) * precision; - const int nsteps = std::max(1, static_cast(norm / step_size)); + const auto nsteps = std::max(1, norm / step_size); OctreeKey prev_key = key; // Walk along the line segment with small steps. Eigen::Vector3f p = leaf_centroid; PointT octree_p; - for (int i = 0; i < nsteps; ++i) { + for (uindex_t i = 0; i < nsteps; ++i) { // Start at the leaf voxel, and move back towards sensor. p += (direction * step_size); diff --git a/octree/include/pcl/octree/impl/octree_pointcloud_voxelcentroid.hpp b/octree/include/pcl/octree/impl/octree_pointcloud_voxelcentroid.hpp index ed3f132f641..f5e6e889cd5 100644 --- a/octree/include/pcl/octree/impl/octree_pointcloud_voxelcentroid.hpp +++ b/octree/include/pcl/octree/impl/octree_pointcloud_voxelcentroid.hpp @@ -70,7 +70,7 @@ pcl::octree::OctreePointCloudVoxelCentroid -std::size_t +pcl::uindex_t pcl::octree::OctreePointCloudVoxelCentroid:: getVoxelCentroids( typename OctreePointCloud:: diff --git a/octree/include/pcl/octree/octree2buf_base.h b/octree/include/pcl/octree/octree2buf_base.h index 632057d1664..84d735c3bea 100644 --- a/octree/include/pcl/octree/octree2buf_base.h +++ b/octree/include/pcl/octree/octree2buf_base.h @@ -212,7 +212,7 @@ class BufferedBranchNode : public OctreeNode { * \ingroup octree * \author Julius Kammerl (julius@kammerl.de) */ -template class Octree2BufBase { @@ -236,7 +236,7 @@ class Octree2BufBase { using Iterator = OctreeDepthFirstIterator; using ConstIterator = const OctreeDepthFirstIterator; Iterator - begin(unsigned int max_depth_arg = 0) + begin(uindex_t max_depth_arg = 0) { return Iterator(this, max_depth_arg); }; @@ -258,7 +258,7 @@ class Octree2BufBase { using ConstLeafNodeDepthFirstIterator = const OctreeLeafNodeDepthFirstIterator; LeafNodeDepthFirstIterator - leaf_depth_begin(unsigned int max_depth_arg = 0) + leaf_depth_begin(uindex_t max_depth_arg = 0) { return LeafNodeDepthFirstIterator(this, max_depth_arg); }; @@ -273,7 +273,7 @@ class Octree2BufBase { using DepthFirstIterator = OctreeDepthFirstIterator; using ConstDepthFirstIterator = const OctreeDepthFirstIterator; DepthFirstIterator - depth_begin(unsigned int maxDepth_arg = 0) + depth_begin(uindex_t maxDepth_arg = 0) { return DepthFirstIterator(this, maxDepth_arg); }; @@ -287,7 +287,7 @@ class Octree2BufBase { using BreadthFirstIterator = OctreeBreadthFirstIterator; using ConstBreadthFirstIterator = const OctreeBreadthFirstIterator; BreadthFirstIterator - breadth_begin(unsigned int max_depth_arg = 0) + breadth_begin(uindex_t max_depth_arg = 0) { return BreadthFirstIterator(this, max_depth_arg); }; @@ -303,7 +303,7 @@ class Octree2BufBase { const OctreeLeafNodeBreadthFirstIterator; LeafNodeBreadthIterator - leaf_breadth_begin(unsigned int max_depth_arg = 0u) + leaf_breadth_begin(uindex_t max_depth_arg = 0u) { return LeafNodeBreadthIterator(this, max_depth_arg ? max_depth_arg : this->octree_depth_); @@ -354,18 +354,18 @@ class Octree2BufBase { * \param max_voxel_index_arg: maximum amount of voxels per dimension */ void - setMaxVoxelIndex(unsigned int max_voxel_index_arg); + setMaxVoxelIndex(uindex_t max_voxel_index_arg); /** \brief Set the maximum depth of the octree. * \param depth_arg: maximum depth of octree */ void - setTreeDepth(unsigned int depth_arg); + setTreeDepth(uindex_t depth_arg); /** \brief Get the maximum depth of the octree. * \return depth_arg: maximum depth of octree */ - inline unsigned int + inline uindex_t getTreeDepth() const { return this->octree_depth_; @@ -379,7 +379,7 @@ class Octree2BufBase { * \return pointer to new leaf node container. */ LeafContainerT* - createLeaf(unsigned int idx_x_arg, unsigned int idx_y_arg, unsigned int idx_z_arg); + createLeaf(uindex_t idx_x_arg, uindex_t idx_y_arg, uindex_t idx_z_arg); /** \brief Find leaf node at (idx_x_arg, idx_y_arg, idx_z_arg). * \note If leaf node already exist, this method returns the existing node @@ -389,7 +389,7 @@ class Octree2BufBase { * \return pointer to leaf node container if found, null pointer otherwise. */ LeafContainerT* - findLeaf(unsigned int idx_x_arg, unsigned int idx_y_arg, unsigned int idx_z_arg); + findLeaf(uindex_t idx_x_arg, uindex_t idx_y_arg, uindex_t idx_z_arg); /** \brief Check for the existence of leaf node at (idx_x_arg, idx_y_arg, idx_z_arg). * \param idx_x_arg: index of leaf node in the X axis. @@ -398,9 +398,7 @@ class Octree2BufBase { * \return "true" if leaf node search is successful, otherwise it returns "false". */ bool - existLeaf(unsigned int idx_x_arg, - unsigned int idx_y_arg, - unsigned int idx_z_arg) const; + existLeaf(uindex_t idx_x_arg, uindex_t idx_y_arg, uindex_t idx_z_arg) const; /** \brief Remove leaf node at (idx_x_arg, idx_y_arg, idx_z_arg). * \param idx_x_arg: index of leaf node in the X axis. @@ -408,7 +406,7 @@ class Octree2BufBase { * \param idx_z_arg: index of leaf node in the Z axis. */ void - removeLeaf(unsigned int idx_x_arg, unsigned int idx_y_arg, unsigned int idx_z_arg); + removeLeaf(uindex_t idx_x_arg, uindex_t idx_y_arg, uindex_t idx_z_arg); /** \brief Return the amount of existing leafs in the octree. * \return amount of registered leaf nodes. @@ -825,9 +823,9 @@ class Octree2BufBase { * \param branch_reset_arg: Reset pointer array of current branch * \return depth mask at which leaf node was created/found **/ - unsigned int + uindex_t createLeafRecursive(const OctreeKey& key_arg, - unsigned int depth_mask_arg, + uindex_t depth_mask_arg, BranchNode* branch_arg, LeafNode*& return_leaf_arg, BranchNode*& parent_of_leaf_arg, @@ -843,7 +841,7 @@ class Octree2BufBase { **/ void findLeafRecursive(const OctreeKey& key_arg, - unsigned int depth_mask_arg, + uindex_t depth_mask_arg, BranchNode* branch_arg, LeafContainerT*& result_arg) const; @@ -857,7 +855,7 @@ class Octree2BufBase { **/ bool deleteLeafRecursive(const OctreeKey& key_arg, - unsigned int depth_mask_arg, + uindex_t depth_mask_arg, BranchNode* branch_arg); /** \brief Recursively explore the octree and output binary octree description @@ -901,7 +899,7 @@ class Octree2BufBase { void deserializeTreeRecursive( BranchNode* branch_arg, - unsigned int depth_mask_arg, + uindex_t depth_mask_arg, OctreeKey& key_arg, typename std::vector::const_iterator& binary_tree_in_it_arg, typename std::vector::const_iterator& binary_tree_in_it_end_arg, @@ -978,7 +976,7 @@ class Octree2BufBase { BranchNode* root_node_; /** \brief Depth mask based on octree depth **/ - unsigned int depth_mask_; + uindex_t depth_mask_; /** \brief key range */ OctreeKey max_key_; @@ -990,7 +988,7 @@ class Octree2BufBase { bool tree_dirty_flag_; /** \brief Octree depth */ - unsigned int octree_depth_; + uindex_t octree_depth_; /** \brief Enable dynamic_depth * \note Note that this parameter is ignored in octree2buf! */ diff --git a/octree/include/pcl/octree/octree_base.h b/octree/include/pcl/octree/octree_base.h index c95b0be55f2..5201f64d4d6 100644 --- a/octree/include/pcl/octree/octree_base.h +++ b/octree/include/pcl/octree/octree_base.h @@ -57,7 +57,7 @@ namespace octree { * \ingroup octree * \author Julius Kammerl (julius@kammerl.de) */ -template class OctreeBase { public: @@ -84,10 +84,10 @@ class OctreeBase { BranchNode* root_node_; /** \brief Depth mask based on octree depth **/ - unsigned int depth_mask_; + uindex_t depth_mask_; /** \brief Octree depth */ - unsigned int octree_depth_; + uindex_t octree_depth_; /** \brief Enable dynamic_depth **/ bool dynamic_depth_enabled_; @@ -109,7 +109,7 @@ class OctreeBase { using ConstIterator = const OctreeDepthFirstIterator; Iterator - begin(unsigned int max_depth_arg = 0u) + begin(uindex_t max_depth_arg = 0u) { return Iterator(this, max_depth_arg ? max_depth_arg : this->octree_depth_); }; @@ -133,7 +133,7 @@ class OctreeBase { const OctreeLeafNodeDepthFirstIterator; LeafNodeDepthFirstIterator - leaf_depth_begin(unsigned int max_depth_arg = 0u) + leaf_depth_begin(uindex_t max_depth_arg = 0u) { return LeafNodeDepthFirstIterator( this, max_depth_arg ? max_depth_arg : this->octree_depth_); @@ -150,7 +150,7 @@ class OctreeBase { using ConstDepthFirstIterator = const OctreeDepthFirstIterator; DepthFirstIterator - depth_begin(unsigned int max_depth_arg = 0u) + depth_begin(uindex_t max_depth_arg = 0u) { return DepthFirstIterator(this, max_depth_arg ? max_depth_arg : this->octree_depth_); @@ -167,7 +167,7 @@ class OctreeBase { using ConstBreadthFirstIterator = const OctreeBreadthFirstIterator; BreadthFirstIterator - breadth_begin(unsigned int max_depth_arg = 0u) + breadth_begin(uindex_t max_depth_arg = 0u) { return BreadthFirstIterator(this, max_depth_arg ? max_depth_arg : this->octree_depth_); @@ -184,7 +184,7 @@ class OctreeBase { using ConstFixedDepthIterator = const OctreeFixedDepthIterator; FixedDepthIterator - fixed_depth_begin(unsigned int fixed_depth_arg = 0u) + fixed_depth_begin(uindex_t fixed_depth_arg = 0u) { return FixedDepthIterator(this, fixed_depth_arg); }; @@ -201,7 +201,7 @@ class OctreeBase { const OctreeLeafNodeBreadthFirstIterator; LeafNodeBreadthFirstIterator - leaf_breadth_begin(unsigned int max_depth_arg = 0u) + leaf_breadth_begin(uindex_t max_depth_arg = 0u) { return LeafNodeBreadthFirstIterator( this, max_depth_arg ? max_depth_arg : this->octree_depth_); @@ -249,18 +249,18 @@ class OctreeBase { * \param[in] max_voxel_index_arg maximum amount of voxels per dimension */ void - setMaxVoxelIndex(unsigned int max_voxel_index_arg); + setMaxVoxelIndex(uindex_t max_voxel_index_arg); /** \brief Set the maximum depth of the octree. * \param max_depth_arg: maximum depth of octree */ void - setTreeDepth(unsigned int max_depth_arg); + setTreeDepth(uindex_t max_depth_arg); /** \brief Get the maximum depth of the octree. * \return depth_arg: maximum depth of octree */ - unsigned int + uindex_t getTreeDepth() const { return this->octree_depth_; @@ -274,7 +274,7 @@ class OctreeBase { * \return pointer to new leaf node container. */ LeafContainerT* - createLeaf(unsigned int idx_x_arg, unsigned int idx_y_arg, unsigned int idx_z_arg); + createLeaf(uindex_t idx_x_arg, uindex_t idx_y_arg, uindex_t idx_z_arg); /** \brief Find leaf node at (idx_x_arg, idx_y_arg, idx_z_arg). * \note If leaf node already exist, this method returns the existing node @@ -284,7 +284,7 @@ class OctreeBase { * \return pointer to leaf node container if found, null pointer otherwise. */ LeafContainerT* - findLeaf(unsigned int idx_x_arg, unsigned int idx_y_arg, unsigned int idx_z_arg); + findLeaf(uindex_t idx_x_arg, uindex_t idx_y_arg, uindex_t idx_z_arg); /** \brief idx_x_arg for the existence of leaf node at (idx_x_arg, idx_y_arg, * idx_z_arg). @@ -294,9 +294,7 @@ class OctreeBase { * \return "true" if leaf node search is successful, otherwise it returns "false". */ bool - existLeaf(unsigned int idx_x_arg, - unsigned int idx_y_arg, - unsigned int idx_z_arg) const; + existLeaf(uindex_t idx_x_arg, uindex_t idx_y_arg, uindex_t idx_z_arg) const; /** \brief Remove leaf node at (idx_x_arg, idx_y_arg, idx_z_arg). * \param idx_x_arg: index of leaf node in the X axis. @@ -304,7 +302,7 @@ class OctreeBase { * \param idx_z_arg: index of leaf node in the Z axis. */ void - removeLeaf(unsigned int idx_x_arg, unsigned int idx_y_arg, unsigned int idx_z_arg); + removeLeaf(uindex_t idx_x_arg, uindex_t idx_y_arg, uindex_t idx_z_arg); /** \brief Return the amount of existing leafs in the octree. * \return amount of registered leaf nodes. @@ -580,9 +578,9 @@ class OctreeBase { * \param parent_of_leaf_arg: return pointer to parent of leaf node * \return depth mask at which leaf node was created **/ - unsigned int + uindex_t createLeafRecursive(const OctreeKey& key_arg, - unsigned int depth_mask_arg, + uindex_t depth_mask_arg, BranchNode* branch_arg, LeafNode*& return_leaf_arg, BranchNode*& parent_of_leaf_arg); @@ -597,7 +595,7 @@ class OctreeBase { **/ void findLeafRecursive(const OctreeKey& key_arg, - unsigned int depth_mask_arg, + uindex_t depth_mask_arg, BranchNode* branch_arg, LeafContainerT*& result_arg) const; @@ -611,7 +609,7 @@ class OctreeBase { **/ bool deleteLeafRecursive(const OctreeKey& key_arg, - unsigned int depth_mask_arg, + uindex_t depth_mask_arg, BranchNode* branch_arg); /** \brief Recursively explore the octree and output binary octree description @@ -644,7 +642,7 @@ class OctreeBase { void deserializeTreeRecursive( BranchNode* branch_arg, - unsigned int depth_mask_arg, + uindex_t depth_mask_arg, OctreeKey& key_arg, typename std::vector::const_iterator& binary_tree_input_it_arg, typename std::vector::const_iterator& binary_tree_input_it_end_arg, diff --git a/octree/include/pcl/octree/octree_container.h b/octree/include/pcl/octree/octree_container.h index a3867aee2cd..fe3074e9e56 100644 --- a/octree/include/pcl/octree/octree_container.h +++ b/octree/include/pcl/octree/octree_container.h @@ -127,7 +127,7 @@ class OctreeContainerEmpty : public OctreeContainerBase { /** \brief Abstract get size of container (number of DataT objects) * \return number of DataT elements in leaf node container. */ - std::size_t + index_t getSize() const override { return 0; @@ -220,24 +220,24 @@ class OctreeContainerPointIndex : public OctreeContainerBase { void getPointIndices(Indices& data_vector_arg) const { - if (data_ >= 0) + if (data_ != static_cast(-1)) data_vector_arg.push_back(data_); } /** \brief Get size of container (number of DataT objects) * \return number of DataT elements in leaf node container. */ - std::size_t + index_t getSize() const override { - return data_ < 0 ? 0 : 1; + return data_ != static_cast(-1) ? 0 : 1; } /** \brief Reset leaf node memory to zero. */ void reset() override { - data_ = -1; + data_ = static_cast(-1); } protected: @@ -316,10 +316,10 @@ class OctreeContainerPointIndices : public OctreeContainerBase { /** \brief Get size of container (number of indices) * \return number of point indices in container. */ - std::size_t + index_t getSize() const override { - return leafDataTVector_.size(); + return static_cast(leafDataTVector_.size()); } /** \brief Reset leaf node. Clear DataT vector.*/ diff --git a/octree/include/pcl/octree/octree_iterator.h b/octree/include/pcl/octree/octree_iterator.h index 2156b3274ca..ae0fbd4c1bd 100644 --- a/octree/include/pcl/octree/octree_iterator.h +++ b/octree/include/pcl/octree/octree_iterator.h @@ -59,7 +59,7 @@ namespace octree { struct IteratorState { OctreeNode* node_; OctreeKey key_; - unsigned int depth_; + uindex_t depth_; }; /** \brief @b Abstract octree iterator class @@ -82,7 +82,7 @@ class OctreeIteratorBase : public std::iteratorreset(); @@ -93,7 +93,7 @@ class OctreeIteratorBase : public std::iteratorreset(); @@ -108,7 +108,7 @@ class OctreeIteratorBase : public std::iteratorgetTreeDepth(); + uindex_t depth = octree_->getTreeDepth(); id = static_cast(key.x) << (depth * 2) | static_cast(key.y) << (depth * 1) | static_cast(key.z) << (depth * 0); @@ -344,7 +344,7 @@ class OctreeIteratorBase : public std::iterator { /** \brief Empty constructor. * \param[in] max_depth_arg Depth limitation during traversal */ - explicit OctreeDepthFirstIterator(unsigned int max_depth_arg = 0); + explicit OctreeDepthFirstIterator(uindex_t max_depth_arg = 0); /** \brief Constructor. * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its * root node. * \param[in] max_depth_arg Depth limitation during traversal */ - explicit OctreeDepthFirstIterator(OctreeT* octree_arg, - unsigned int max_depth_arg = 0); + explicit OctreeDepthFirstIterator(OctreeT* octree_arg, uindex_t max_depth_arg = 0); /** \brief Constructor. * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its @@ -384,7 +383,7 @@ class OctreeDepthFirstIterator : public OctreeIteratorBase { */ explicit OctreeDepthFirstIterator( OctreeT* octree_arg, - unsigned int max_depth_arg, + uindex_t max_depth_arg, IteratorState* current_state, const std::vector& stack = std::vector()) : OctreeIteratorBase(octree_arg, max_depth_arg, current_state), stack_(stack) @@ -469,15 +468,14 @@ class OctreeBreadthFirstIterator : public OctreeIteratorBase { /** \brief Empty constructor. * \param[in] max_depth_arg Depth limitation during traversal */ - explicit OctreeBreadthFirstIterator(unsigned int max_depth_arg = 0); + explicit OctreeBreadthFirstIterator(uindex_t max_depth_arg = 0); /** \brief Constructor. * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its * root node. * \param[in] max_depth_arg Depth limitation during traversal */ - explicit OctreeBreadthFirstIterator(OctreeT* octree_arg, - unsigned int max_depth_arg = 0); + explicit OctreeBreadthFirstIterator(OctreeT* octree_arg, uindex_t max_depth_arg = 0); /** \brief Constructor. * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its @@ -489,7 +487,7 @@ class OctreeBreadthFirstIterator : public OctreeIteratorBase { */ explicit OctreeBreadthFirstIterator( OctreeT* octree_arg, - unsigned int max_depth_arg, + uindex_t max_depth_arg, IteratorState* current_state, const std::deque& fifo = std::deque()) : OctreeIteratorBase(octree_arg, max_depth_arg, current_state), FIFO_(fifo) @@ -575,8 +573,7 @@ class OctreeFixedDepthIterator : public OctreeBreadthFirstIterator { * root node. * \param[in] fixed_depth_arg Depth level during traversal */ - explicit OctreeFixedDepthIterator(OctreeT* octree_arg, - unsigned int fixed_depth_arg = 0); + explicit OctreeFixedDepthIterator(OctreeT* octree_arg, uindex_t fixed_depth_arg = 0); /** \brief Constructor. * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its @@ -589,7 +586,7 @@ class OctreeFixedDepthIterator : public OctreeBreadthFirstIterator { */ OctreeFixedDepthIterator( OctreeT* octree_arg, - unsigned int fixed_depth_arg, + uindex_t fixed_depth_arg, IteratorState* current_state, const std::deque& fifo = std::deque()) : OctreeBreadthFirstIterator( @@ -623,7 +620,7 @@ class OctreeFixedDepthIterator : public OctreeBreadthFirstIterator { * \param[in] fixed_depth_arg Depth level during traversal */ void - reset(unsigned int fixed_depth_arg); + reset(uindex_t fixed_depth_arg); /** \brief Reset the iterator to the first node at the current depth */ @@ -637,7 +634,7 @@ class OctreeFixedDepthIterator : public OctreeBreadthFirstIterator { using OctreeBreadthFirstIterator::FIFO_; /** \brief Given level of the node to be iterated */ - unsigned int fixed_depth_; + uindex_t fixed_depth_; }; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -657,7 +654,7 @@ class OctreeLeafNodeDepthFirstIterator : public OctreeDepthFirstIterator(max_depth_arg) { reset(); @@ -669,7 +666,7 @@ class OctreeLeafNodeDepthFirstIterator : public OctreeDepthFirstIterator(octree_arg, max_depth_arg) { reset(); @@ -685,7 +682,7 @@ class OctreeLeafNodeDepthFirstIterator : public OctreeDepthFirstIterator& stack = std::vector()) : OctreeDepthFirstIterator(octree_arg, max_depth_arg, current_state, stack) @@ -759,7 +756,7 @@ class OctreeLeafNodeBreadthFirstIterator : public OctreeBreadthFirstIterator& fifo = std::deque()); diff --git a/octree/include/pcl/octree/octree_key.h b/octree/include/pcl/octree/octree_key.h index a103d5a31db..508f29ad7a7 100644 --- a/octree/include/pcl/octree/octree_key.h +++ b/octree/include/pcl/octree/octree_key.h @@ -140,17 +140,17 @@ class OctreeKey { /* \brief maximum depth that can be addressed */ static const unsigned char maxDepth = - static_cast(sizeof(std::uint32_t) * 8); + static_cast(sizeof(uindex_t) * 8); // Indices addressing a voxel at (X, Y, Z) union { struct { - std::uint32_t x; - std::uint32_t y; - std::uint32_t z; + uindex_t x; + uindex_t y; + uindex_t z; }; - std::uint32_t key_[3]; + uindex_t key_[3]; }; }; } // namespace octree diff --git a/octree/include/pcl/octree/octree_pointcloud.h b/octree/include/pcl/octree/octree_pointcloud.h index 8d7fabc7beb..aad4f2cfd82 100644 --- a/octree/include/pcl/octree/octree_pointcloud.h +++ b/octree/include/pcl/octree/octree_pointcloud.h @@ -279,7 +279,7 @@ class OctreePointCloud : public OctreeT { * octree_resolution x precision * \return number of intersected voxels */ - int + index_t getApproxIntersectedVoxelCentersBySegment(const Eigen::Vector3f& origin, const Eigen::Vector3f& end, AlignedPointTVector& voxel_center_list, diff --git a/octree/src/octree_inst.cpp b/octree/src/octree_inst.cpp index e0d266508ab..2f149f0b487 100644 --- a/octree/src/octree_inst.cpp +++ b/octree/src/octree_inst.cpp @@ -39,8 +39,8 @@ // Instantiations of specific point types -template class PCL_EXPORTS pcl::octree::OctreeBase; -template class PCL_EXPORTS pcl::octree::Octree2BufBase; +template class PCL_EXPORTS pcl::octree::OctreeBase; +template class PCL_EXPORTS pcl::octree::Octree2BufBase; template class PCL_EXPORTS pcl::octree::OctreeBase Date: Sat, 19 Sep 2020 21:45:07 +0900 Subject: [PATCH 05/12] Trying to make octree tests pass compile --- .../octree_pointcloud_compression.h | 2 +- kdtree/include/pcl/kdtree/impl/io.hpp | 8 ++-- .../include/pcl/kdtree/impl/kdtree_flann.hpp | 16 ++++---- kdtree/include/pcl/kdtree/io.h | 4 +- kdtree/include/pcl/kdtree/kdtree.h | 20 +++++----- kdtree/include/pcl/kdtree/kdtree_flann.h | 12 +++--- .../pcl/octree/impl/octree_iterator.hpp | 3 +- octree/include/pcl/octree/octree_container.h | 2 +- octree/include/pcl/octree/octree_iterator.h | 18 +++++++-- octree/include/pcl/octree/octree_pointcloud.h | 4 +- .../octree_pointcloud_adjacency_container.h | 2 +- test/octree/test_octree.cpp | 38 +++++++++---------- 12 files changed, 70 insertions(+), 59 deletions(-) diff --git a/io/include/pcl/compression/octree_pointcloud_compression.h b/io/include/pcl/compression/octree_pointcloud_compression.h index d251d35e7b6..4a742179d91 100644 --- a/io/include/pcl/compression/octree_pointcloud_compression.h +++ b/io/include/pcl/compression/octree_pointcloud_compression.h @@ -158,7 +158,7 @@ namespace pcl * \param[in] pointIdx_arg the index representing the point in the dataset given by \a setInputCloud to be added */ void - addPointIdx (const int pointIdx_arg) override + addPointIdx (const index_t pointIdx_arg) override { ++object_count_; OctreePointCloud::addPointIdx(pointIdx_arg); diff --git a/kdtree/include/pcl/kdtree/impl/io.hpp b/kdtree/include/pcl/kdtree/impl/io.hpp index 4e577beeb59..921b42bb3c7 100644 --- a/kdtree/include/pcl/kdtree/impl/io.hpp +++ b/kdtree/include/pcl/kdtree/impl/io.hpp @@ -47,12 +47,12 @@ template void pcl::getApproximateIndices ( const typename pcl::PointCloud::ConstPtr &cloud_in, const typename pcl::PointCloud::ConstPtr &cloud_ref, - std::vector &indices) + Indices &indices) { pcl::KdTreeFLANN tree; tree.setInputCloud (cloud_ref); - std::vector nn_idx (1); + Indices nn_idx (1); std::vector nn_dists (1); indices.resize (cloud_in->size ()); for (std::size_t i = 0; i < cloud_in->size (); ++i) @@ -67,12 +67,12 @@ template void pcl::getApproximateIndices ( const typename pcl::PointCloud::ConstPtr &cloud_in, const typename pcl::PointCloud::ConstPtr &cloud_ref, - std::vector &indices) + Indices &indices) { pcl::KdTreeFLANN tree; tree.setInputCloud (cloud_ref); - std::vector nn_idx (1); + Indices nn_idx (1); std::vector nn_dists (1); indices.resize (cloud_in->size ()); for (std::size_t i = 0; i < cloud_in->size (); ++i) diff --git a/kdtree/include/pcl/kdtree/impl/kdtree_flann.hpp b/kdtree/include/pcl/kdtree/impl/kdtree_flann.hpp index 8d5959e7da7..923764f0631 100644 --- a/kdtree/include/pcl/kdtree/impl/kdtree_flann.hpp +++ b/kdtree/include/pcl/kdtree/impl/kdtree_flann.hpp @@ -128,9 +128,9 @@ pcl::KdTreeFLANN::setInputCloud (const PointCloudConstPtr &cloud, } /////////////////////////////////////////////////////////////////////////////////////////// -template int +template int pcl::KdTreeFLANN::nearestKSearch (const PointT &point, unsigned int k, - std::vector &k_indices, + Indices &k_indices, std::vector &k_distances) const { assert (point_representation_->isValid (point) && "Invalid (NaN, Inf) point coordinates given to nearestKSearch!"); @@ -147,7 +147,7 @@ pcl::KdTreeFLANN::nearestKSearch (const PointT &point, unsigned in std::vector query (dim_); point_representation_->vectorize (static_cast (point), query); - ::flann::Matrix k_indices_mat (&k_indices[0], 1, k); + ::flann::Matrix k_indices_mat (&k_indices[0], 1, k); ::flann::Matrix k_distances_mat (&k_distances[0], 1, k); // Wrap the k_indices and k_distances vectors (no data copy) flann_index_->knnSearch (::flann::Matrix (&query[0], 1, dim_), @@ -159,7 +159,7 @@ pcl::KdTreeFLANN::nearestKSearch (const PointT &point, unsigned in { for (std::size_t i = 0; i < static_cast (k); ++i) { - int& neighbor_index = k_indices[i]; + auto& neighbor_index = k_indices[i]; neighbor_index = index_mapping_[neighbor_index]; } } @@ -169,7 +169,7 @@ pcl::KdTreeFLANN::nearestKSearch (const PointT &point, unsigned in /////////////////////////////////////////////////////////////////////////////////////////// template int -pcl::KdTreeFLANN::radiusSearch (const PointT &point, double radius, std::vector &k_indices, +pcl::KdTreeFLANN::radiusSearch (const PointT &point, double radius, Indices &k_indices, std::vector &k_sqr_dists, unsigned int max_nn) const { assert (point_representation_->isValid (point) && "Invalid (NaN, Inf) point coordinates given to radiusSearch!"); @@ -181,7 +181,7 @@ pcl::KdTreeFLANN::radiusSearch (const PointT &point, double radius if (max_nn == 0 || max_nn > total_nr_points_) max_nn = total_nr_points_; - std::vector > indices(1); + std::vector indices(1); std::vector > dists(1); ::flann::SearchParams params (param_radius_); @@ -204,7 +204,7 @@ pcl::KdTreeFLANN::radiusSearch (const PointT &point, double radius { for (int i = 0; i < neighbors_in_radius; ++i) { - int& neighbor_index = k_indices[i]; + auto& neighbor_index = k_indices[i]; neighbor_index = index_mapping_[neighbor_index]; } } @@ -259,7 +259,7 @@ pcl::KdTreeFLANN::convertCloudToArray (const PointCloud &cloud) /////////////////////////////////////////////////////////////////////////////////////////// template void -pcl::KdTreeFLANN::convertCloudToArray (const PointCloud &cloud, const std::vector &indices) +pcl::KdTreeFLANN::convertCloudToArray (const PointCloud &cloud, const Indices &indices) { // No point in doing anything if the array is empty if (cloud.empty ()) diff --git a/kdtree/include/pcl/kdtree/io.h b/kdtree/include/pcl/kdtree/io.h index a3ebb21f808..071340dcca6 100644 --- a/kdtree/include/pcl/kdtree/io.h +++ b/kdtree/include/pcl/kdtree/io.h @@ -55,7 +55,7 @@ namespace pcl template void getApproximateIndices (const typename pcl::PointCloud::ConstPtr &cloud_in, const typename pcl::PointCloud::ConstPtr &cloud_ref, - std::vector &indices); + Indices &indices); /** \brief Get a set of approximate indices for a given point cloud into a reference point cloud. * The coordinates of the two point clouds can differ. The method uses an internal KdTree for @@ -69,7 +69,7 @@ namespace pcl template void getApproximateIndices (const typename pcl::PointCloud::ConstPtr &cloud_in, const typename pcl::PointCloud::ConstPtr &cloud_ref, - std::vector &indices); + Indices &indices); } #include diff --git a/kdtree/include/pcl/kdtree/kdtree.h b/kdtree/include/pcl/kdtree/kdtree.h index 5d5e5034f21..82baf32a49c 100644 --- a/kdtree/include/pcl/kdtree/kdtree.h +++ b/kdtree/include/pcl/kdtree/kdtree.h @@ -54,8 +54,8 @@ namespace pcl class KdTree { public: - using IndicesPtr = shared_ptr >; - using IndicesConstPtr = shared_ptr >; + using IndicesPtr = shared_ptr; + using IndicesConstPtr = shared_ptr; using PointCloud = pcl::PointCloud; using PointCloudPtr = typename PointCloud::Ptr; @@ -133,7 +133,7 @@ namespace pcl */ virtual int nearestKSearch (const PointT &p_q, unsigned int k, - std::vector &k_indices, std::vector &k_sqr_distances) const = 0; + Indices &k_indices, std::vector &k_sqr_distances) const = 0; /** \brief Search for k-nearest neighbors for the given query point. * @@ -153,7 +153,7 @@ namespace pcl */ virtual int nearestKSearch (const PointCloud &cloud, int index, unsigned int k, - std::vector &k_indices, std::vector &k_sqr_distances) const + Indices &k_indices, std::vector &k_sqr_distances) const { assert (index >= 0 && index < static_cast (cloud.size ()) && "Out-of-bounds error in nearestKSearch!"); return (nearestKSearch (cloud[index], k, k_indices, k_sqr_distances)); @@ -170,7 +170,7 @@ namespace pcl */ template inline int nearestKSearchT (const PointTDiff &point, unsigned int k, - std::vector &k_indices, std::vector &k_sqr_distances) const + Indices &k_indices, std::vector &k_sqr_distances) const { PointT p; copyPoint (point, p); @@ -196,7 +196,7 @@ namespace pcl */ virtual int nearestKSearch (int index, unsigned int k, - std::vector &k_indices, std::vector &k_sqr_distances) const + Indices &k_indices, std::vector &k_sqr_distances) const { if (indices_ == nullptr) { @@ -219,7 +219,7 @@ namespace pcl * \return number of neighbors found in radius */ virtual int - radiusSearch (const PointT &p_q, double radius, std::vector &k_indices, + radiusSearch (const PointT &p_q, double radius, Indices &k_indices, std::vector &k_sqr_distances, unsigned int max_nn = 0) const = 0; /** \brief Search for all the nearest neighbors of the query point in a given radius. @@ -241,7 +241,7 @@ namespace pcl */ virtual int radiusSearch (const PointCloud &cloud, int index, double radius, - std::vector &k_indices, std::vector &k_sqr_distances, + Indices &k_indices, std::vector &k_sqr_distances, unsigned int max_nn = 0) const { assert (index >= 0 && index < static_cast (cloud.size ()) && "Out-of-bounds error in radiusSearch!"); @@ -259,7 +259,7 @@ namespace pcl * \return number of neighbors found in radius */ template inline int - radiusSearchT (const PointTDiff &point, double radius, std::vector &k_indices, + radiusSearchT (const PointTDiff &point, double radius, Indices &k_indices, std::vector &k_sqr_distances, unsigned int max_nn = 0) const { PointT p; @@ -287,7 +287,7 @@ namespace pcl * \exception asserts in debug mode if the index is not between 0 and the maximum number of points */ virtual int - radiusSearch (int index, double radius, std::vector &k_indices, + radiusSearch (int index, double radius, Indices &k_indices, std::vector &k_sqr_distances, unsigned int max_nn = 0) const { if (indices_ == nullptr) diff --git a/kdtree/include/pcl/kdtree/kdtree_flann.h b/kdtree/include/pcl/kdtree/kdtree_flann.h index bf053ac0b65..50e2190a637 100644 --- a/kdtree/include/pcl/kdtree/kdtree_flann.h +++ b/kdtree/include/pcl/kdtree/kdtree_flann.h @@ -75,8 +75,8 @@ namespace pcl using PointCloud = typename KdTree::PointCloud; using PointCloudConstPtr = typename KdTree::PointCloudConstPtr; - using IndicesPtr = shared_ptr >; - using IndicesConstPtr = shared_ptr >; + using IndicesPtr = shared_ptr; + using IndicesConstPtr = shared_ptr; using FLANNIndex = ::flann::Index; @@ -154,9 +154,9 @@ namespace pcl * * \exception asserts in debug mode if the index is not between 0 and the maximum number of points */ - int + int nearestKSearch (const PointT &point, unsigned int k, - std::vector &k_indices, std::vector &k_sqr_distances) const override; + Indices &k_indices, std::vector &k_sqr_distances) const override; /** \brief Search for all the nearest neighbors of the query point in a given radius. * @@ -175,7 +175,7 @@ namespace pcl * \exception asserts in debug mode if the index is not between 0 and the maximum number of points */ int - radiusSearch (const PointT &point, double radius, std::vector &k_indices, + radiusSearch (const PointT &point, double radius, Indices &k_indices, std::vector &k_sqr_distances, unsigned int max_nn = 0) const override; private: @@ -196,7 +196,7 @@ namespace pcl * \param[in] indices the point cloud indices */ void - convertCloudToArray (const PointCloud &cloud, const std::vector &indices); + convertCloudToArray (const PointCloud &cloud, const Indices &indices); private: /** \brief Class getName method. */ diff --git a/octree/include/pcl/octree/impl/octree_iterator.hpp b/octree/include/pcl/octree/impl/octree_iterator.hpp index bb0d7719e7a..6a394ab1545 100644 --- a/octree/include/pcl/octree/impl/octree_iterator.hpp +++ b/octree/include/pcl/octree/impl/octree_iterator.hpp @@ -257,8 +257,7 @@ OctreeBreadthFirstIterator::operator++() ////////////////////////////////////////////////////////////////////////////////////////////// template -OctreeFixedDepthIterator::OctreeFixedDepthIterator() -: OctreeBreadthFirstIterator(0u), fixed_depth_(0u) +OctreeFixedDepthIterator::OctreeFixedDepthIterator() : fixed_depth_(0u) {} ////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/octree/include/pcl/octree/octree_container.h b/octree/include/pcl/octree/octree_container.h index fe3074e9e56..d860f016c1c 100644 --- a/octree/include/pcl/octree/octree_container.h +++ b/octree/include/pcl/octree/octree_container.h @@ -76,7 +76,7 @@ class OctreeContainerBase { /** \brief Pure abstract method to get size of container (number of indices) * \return number of points/indices stored in leaf node container. */ - virtual std::size_t + virtual index_t getSize() const { return 0u; diff --git a/octree/include/pcl/octree/octree_iterator.h b/octree/include/pcl/octree/octree_iterator.h index ae0fbd4c1bd..2c1a848d33f 100644 --- a/octree/include/pcl/octree/octree_iterator.h +++ b/octree/include/pcl/octree/octree_iterator.h @@ -82,8 +82,13 @@ class OctreeIteratorBase : public std::iteratorreset(); } @@ -93,7 +98,14 @@ class OctreeIteratorBase : public std::iteratorreset(); diff --git a/octree/include/pcl/octree/octree_pointcloud.h b/octree/include/pcl/octree/octree_pointcloud.h index aad4f2cfd82..66afc625c41 100644 --- a/octree/include/pcl/octree/octree_pointcloud.h +++ b/octree/include/pcl/octree/octree_pointcloud.h @@ -183,7 +183,7 @@ class OctreePointCloud : public OctreeT { /** \brief Get the maximum depth of the octree. * \return depth_arg: maximum depth of octree * */ - inline unsigned int + inline uindex_t getTreeDepth() const { return this->octree_depth_; @@ -440,7 +440,7 @@ class OctreePointCloud : public OctreeT { expandLeafNode(LeafNode* leaf_node, BranchNode* parent_branch, unsigned char child_idx, - unsigned int depth_mask); + uindex_t depth_mask); /** \brief Get point at index from input pointcloud dataset * \param[in] index_arg index representing the point in the dataset given by \a diff --git a/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h b/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h index f79f53e0d81..18a0414d657 100644 --- a/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h +++ b/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h @@ -119,7 +119,7 @@ class OctreePointCloudAdjacencyContainer : public OctreeContainerBase { /** \brief virtual method to get size of container * \return number of points added to leaf node container. */ - std::size_t + index_t getSize() const override { return num_points_; diff --git a/test/octree/test_octree.cpp b/test/octree/test_octree.cpp index 7e24a46f18b..b2c7e579a93 100644 --- a/test/octree/test_octree.cpp +++ b/test/octree/test_octree.cpp @@ -308,7 +308,7 @@ TEST (PCL, Octree_Dynamic_Depth_Test) // test iterator unsigned int leaf_count = 0; - std::vector indexVector; + Indices indexVector; // iterate over tree for (auto it = octree.leaf_depth_begin(), it_end = octree.leaf_depth_end(); it != it_end; ++it) @@ -329,13 +329,13 @@ TEST (PCL, Octree_Dynamic_Depth_Test) container.getPointIndices (indexVector); // test points against bounding box of leaf node - std::vector tmpVector; + Indices tmpVector; container.getPointIndices (tmpVector); Eigen::Vector3f min_pt, max_pt; octree.getVoxelBounds (it, min_pt, max_pt); - for (const int &i : tmpVector) + for (const auto &i : tmpVector) { ASSERT_GE ((*cloud)[i].x, min_pt(0)); ASSERT_GE ((*cloud)[i].y, min_pt(1)); @@ -477,7 +477,7 @@ TEST (PCL, Octree2Buf_Test) leafVectorA.pop_back (); bool bFound = false; - for (const int &value : data) + for (const auto &value : data) if (value == leafInt) { bFound = true; @@ -496,7 +496,7 @@ TEST (PCL, Octree2Buf_Test) leafVectorA.pop_back (); bool bFound = false; - for (const int &value : data) + for (const auto &value : data) if (value == leafInt) { bFound = true; @@ -790,12 +790,12 @@ TEST (PCL, Octree_Pointcloud_Test) for (std::size_t i = 0; i < cloudB->size (); i++) { - std::vector pointIdxVec; + Indices pointIdxVec; octreeB.voxelSearch ((*cloudB)[i], pointIdxVec); bool bIdxFound = false; - std::vector::const_iterator current = pointIdxVec.begin (); - while (current != pointIdxVec.end ()) + auto current = pointIdxVec.cbegin (); + while (current != pointIdxVec.cend ()) { if (*current == static_cast (i)) { @@ -869,7 +869,7 @@ TEST (PCL, Octree_Pointcloud_Iterator_Test) octreeA.setInputCloud (cloudIn); octreeA.addPointsFromInputCloud (); - std::vector indexVector; + Indices indexVector; unsigned int leafNodeCounter = 0; for (auto it1 = octreeA.leaf_depth_begin(), it1_end = octreeA.leaf_depth_end(); it1 != it1_end; ++it1) @@ -1007,7 +1007,7 @@ TEST (PCL, Octree_Pointcloud_Change_Detector_Test) cloudIn); } - std::vector newPointIdxVector; + Indices newPointIdxVector; // get a vector of new points, which did not exist in previous buffer octree.getPointIndicesFromNewVoxels (newPointIdxVector); @@ -1136,10 +1136,10 @@ TEST (PCL, Octree_Pointcloud_Nearest_K_Neighbour_Search) OctreePointCloudSearch octree (0.1); octree.setInputCloud (cloudIn); - std::vector k_indices; + Indices k_indices; std::vector k_sqr_distances; - std::vector k_indices_bruteforce; + Indices k_indices_bruteforce; std::vector k_sqr_distances_bruteforce; for (unsigned int test_id = 0; test_id < test_runs; test_id++) @@ -1235,7 +1235,7 @@ TEST (PCL, Octree_Pointcloud_Box_Search) for (unsigned int test_id = 0; test_id < test_runs; test_id++) { - std::vector k_indices; + Indices k_indices; // generate point cloud cloudIn->width = 300; @@ -1341,7 +1341,7 @@ TEST(PCL, Octree_Pointcloud_Approx_Nearest_Neighbour_Search) } - int ANNindex; + index_t ANNindex; float ANNdistance; // octree approx. nearest neighbor search @@ -1415,7 +1415,7 @@ TEST (PCL, Octree_Pointcloud_Neighbours_Within_Radius_Search) } } - std::vector cloudNWRSearch; + Indices cloudNWRSearch; std::vector cloudNWRRadius; // execute octree radius search @@ -1424,8 +1424,8 @@ TEST (PCL, Octree_Pointcloud_Neighbours_Within_Radius_Search) ASSERT_EQ (cloudSearchBruteforce.size (), cloudNWRRadius.size ()); // check if result from octree radius search can be also found in bruteforce search - std::vector::const_iterator current = cloudNWRSearch.begin (); - while (current != cloudNWRSearch.end ()) + auto current = cloudNWRSearch.cbegin (); + while (current != cloudNWRSearch.cend ()) { pointDist = sqrt ( ((*cloudIn)[*current].x - searchPoint.x) * ((*cloudIn)[*current].x - searchPoint.x) @@ -1459,7 +1459,7 @@ TEST (PCL, Octree_Pointcloud_Ray_Traversal) pcl::PointCloud::VectorType voxelsInRay, voxelsInRay2; // Indices in ray - std::vector indicesInRay, indicesInRay2; + Indices indicesInRay, indicesInRay2; srand (static_cast (time (nullptr))); @@ -1620,7 +1620,7 @@ TEST (PCL, Octree_Pointcloud_Bounds) const double LARGE_MAX = 1e7-5*SOME_RESOLUTION; tree.defineBoundingBox (LARGE_MIN, LARGE_MIN, LARGE_MIN, LARGE_MAX, LARGE_MAX, LARGE_MAX); tree.getBoundingBox (min_x, min_y, min_z, max_x, max_y, max_z); - const unsigned int depth = tree.getTreeDepth (); + const auto depth = tree.getTreeDepth (); tree.defineBoundingBox (min_x, min_y, min_z, max_x, max_y, max_z); ASSERT_EQ (depth, tree.getTreeDepth ()); From 36162eb1a3fb39ebe8d87955d3b7b623de035847 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Sat, 19 Sep 2020 22:25:41 +0900 Subject: [PATCH 06/12] octree_pointcloud left --- octree/include/pcl/octree/impl/octree_pointcloud.hpp | 2 +- octree/include/pcl/octree/octree_container.h | 4 +--- octree/include/pcl/octree/octree_key.h | 6 ++---- .../pcl/octree/octree_pointcloud_adjacency_container.h | 4 ++-- .../include/pcl/octree/octree_pointcloud_changedetector.h | 4 ++-- octree/include/pcl/octree/octree_pointcloud_density.h | 4 ++-- 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/octree/include/pcl/octree/impl/octree_pointcloud.hpp b/octree/include/pcl/octree/impl/octree_pointcloud.hpp index bf3e5a5dc75..22f5b909390 100644 --- a/octree/include/pcl/octree/impl/octree_pointcloud.hpp +++ b/octree/include/pcl/octree/impl/octree_pointcloud.hpp @@ -605,7 +605,7 @@ pcl::octree::OctreePointCloud expandLeafNode(LeafNode* leaf_node, BranchNode* parent_branch, unsigned char child_idx, - unsigned int depth_mask) + uindex_t depth_mask) { if (depth_mask) { diff --git a/octree/include/pcl/octree/octree_container.h b/octree/include/pcl/octree/octree_container.h index d860f016c1c..049ca9855c2 100644 --- a/octree/include/pcl/octree/octree_container.h +++ b/octree/include/pcl/octree/octree_container.h @@ -141,9 +141,7 @@ class OctreeContainerEmpty : public OctreeContainerBase { /** \brief Empty addPointIndex implementation. This leaf node does not store any point * indices. */ - void - addPointIndex(int) - {} + void addPointIndex(index_t) {} /** \brief Empty getPointIndex implementation as this leaf node does not store any * point indices. diff --git a/octree/include/pcl/octree/octree_key.h b/octree/include/pcl/octree/octree_key.h index 508f29ad7a7..4e676221140 100644 --- a/octree/include/pcl/octree/octree_key.h +++ b/octree/include/pcl/octree/octree_key.h @@ -55,9 +55,7 @@ class OctreeKey { OctreeKey() : x(0), y(0), z(0) {} /** \brief Constructor for key initialization. */ - OctreeKey(unsigned int keyX, unsigned int keyY, unsigned int keyZ) - : x(keyX), y(keyY), z(keyZ) - {} + OctreeKey(uindex_t keyX, uindex_t keyY, uindex_t keyZ) : x(keyX), y(keyY), z(keyZ) {} /** \brief Copy constructor. */ OctreeKey(const OctreeKey& source) { std::memcpy(key_, source.key_, sizeof(key_)); } @@ -131,7 +129,7 @@ class OctreeKey { * \return child node index * */ inline unsigned char - getChildIdxWithDepthMask(unsigned int depthMask) const + getChildIdxWithDepthMask(uindex_t depthMask) const { return static_cast(((!!(this->x & depthMask)) << 2) | ((!!(this->y & depthMask)) << 1) | diff --git a/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h b/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h index 18a0414d657..a5bc2a2a25b 100644 --- a/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h +++ b/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h @@ -94,7 +94,7 @@ class OctreePointCloudAdjacencyContainer : public OctreeContainerBase { } /** \brief Gets the number of points contributing to this leaf */ - int + uindex_t getPointCounter() const { return num_points_; @@ -122,7 +122,7 @@ class OctreePointCloudAdjacencyContainer : public OctreeContainerBase { index_t getSize() const override { - return num_points_; + return static_cast(num_points_); } protected: diff --git a/octree/include/pcl/octree/octree_pointcloud_changedetector.h b/octree/include/pcl/octree/octree_pointcloud_changedetector.h index fd06d3beca6..b240fb8b53d 100644 --- a/octree/include/pcl/octree/octree_pointcloud_changedetector.h +++ b/octree/include/pcl/octree/octree_pointcloud_changedetector.h @@ -92,14 +92,14 @@ class OctreePointCloudChangeDetector */ std::size_t getPointIndicesFromNewVoxels(Indices& indicesVector_arg, - const int minPointsPerLeaf_arg = 0) + const index_t minPointsPerLeaf_arg = 0) { std::vector leaf_containers; this->serializeNewLeafs(leaf_containers); for (const auto& leaf_container : leaf_containers) { - if (static_cast(leaf_container->getSize()) >= minPointsPerLeaf_arg) + if (static_cast(leaf_container->getSize()) >= minPointsPerLeaf_arg) leaf_container->getPointIndices(indicesVector_arg); } diff --git a/octree/include/pcl/octree/octree_pointcloud_density.h b/octree/include/pcl/octree/octree_pointcloud_density.h index 61545019577..1083c20a059 100644 --- a/octree/include/pcl/octree/octree_pointcloud_density.h +++ b/octree/include/pcl/octree/octree_pointcloud_density.h @@ -76,12 +76,12 @@ class OctreePointCloudDensityContainer : public OctreeContainerBase { /** \brief Read input data. Only an internal counter is increased. */ - void addPointIndex(index_t) { point_counter_++; } + void addPointIndex(uindex_t) { point_counter_++; } /** \brief Return point counter. * \return Amount of points */ - unsigned int + uindex_t getPointCounter() { return (point_counter_); From fd2e2e812e9e7907ea35e5c5e9a6c66a824273d8 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Sun, 20 Sep 2020 00:14:06 +0900 Subject: [PATCH 07/12] Better octree-pointcloud --- .../pcl/octree/impl/octree_pointcloud.hpp | 51 ++++++++----------- 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/octree/include/pcl/octree/impl/octree_pointcloud.hpp b/octree/include/pcl/octree/impl/octree_pointcloud.hpp index 22f5b909390..2d16c658708 100644 --- a/octree/include/pcl/octree/impl/octree_pointcloud.hpp +++ b/octree/include/pcl/octree/impl/octree_pointcloud.hpp @@ -278,14 +278,14 @@ pcl::octree::OctreePointCloud const float step_size = static_cast(resolution_) * precision; // Ensure we get at least one step for the first voxel. - const int nsteps = std::max(1, static_cast(norm / step_size)); + const auto nsteps = std::max(1, norm / step_size); OctreeKey prev_key; bool bkeyDefined = false; // Walk along the line segment with small steps. - for (int i = 0; i < nsteps; ++i) { + for (std::size_t i = 0; i < nsteps; ++i) { Eigen::Vector3f p = origin + (direction * step_size * static_cast(i)); PointT octree_p; @@ -668,7 +668,7 @@ pcl::octree::OctreePointCloud LeafNode* leaf_node; BranchNode* parent_branch_of_leaf_node; - unsigned int depth_mask = this->createLeafRecursive( + auto depth_mask = this->createLeafRecursive( key, this->depth_mask_, this->root_node_, leaf_node, parent_branch_of_leaf_node); if (this->dynamic_depth_enabled_ && depth_mask) { @@ -716,36 +716,28 @@ void pcl::octree::OctreePointCloud:: getKeyBitSize() { - unsigned int max_voxels; - - unsigned int max_key_x; - unsigned int max_key_y; - unsigned int max_key_z; - - double octree_side_len; - const float minValue = std::numeric_limits::epsilon(); // find maximum key values for x, y, z - max_key_x = - static_cast(std::ceil((max_x_ - min_x_ - minValue) / resolution_)); - max_key_y = - static_cast(std::ceil((max_y_ - min_y_ - minValue) / resolution_)); - max_key_z = - static_cast(std::ceil((max_z_ - min_z_ - minValue) / resolution_)); + const auto max_key_x = + static_cast(std::ceil((max_x_ - min_x_ - minValue) / resolution_)); + const auto max_key_y = + static_cast(std::ceil((max_y_ - min_y_ - minValue) / resolution_)); + const auto max_key_z = + static_cast(std::ceil((max_z_ - min_z_ - minValue) / resolution_)); // find maximum amount of keys - max_voxels = std::max(std::max(std::max(max_key_x, max_key_y), max_key_z), - static_cast(2)); + const auto max_voxels = + std::max(std::max(std::max(max_key_x, max_key_y), max_key_z), 2); // tree depth == amount of bits of max_voxels - this->octree_depth_ = - std::max((std::min(static_cast(OctreeKey::maxDepth), - static_cast( - std::ceil(std::log2(max_voxels) - minValue)))), - static_cast(0)); + this->octree_depth_ = std::max( + std::min(OctreeKey::maxDepth, + std::ceil(std::log2(max_voxels) - minValue)), + 0); - octree_side_len = static_cast(1 << this->octree_depth_) * resolution_; + const auto octree_side_len = + static_cast(1 << this->octree_depth_) * resolution_; if (this->leaf_count_ == 0) { double octree_oversize_x; @@ -793,12 +785,9 @@ pcl::octree::OctreePointCloud genOctreeKeyforPoint(const PointT& point_arg, OctreeKey& key_arg) const { // calculate integer key for point coordinates - key_arg.x = - static_cast((point_arg.x - this->min_x_) / this->resolution_); - key_arg.y = - static_cast((point_arg.y - this->min_y_) / this->resolution_); - key_arg.z = - static_cast((point_arg.z - this->min_z_) / this->resolution_); + key_arg.x = static_cast((point_arg.x - this->min_x_) / this->resolution_); + key_arg.y = static_cast((point_arg.y - this->min_y_) / this->resolution_); + key_arg.z = static_cast((point_arg.z - this->min_z_) / this->resolution_); assert(key_arg.x <= this->max_key_.x); assert(key_arg.y <= this->max_key_.y); From 85bfe05e43d6cfd5ff9ad0119b981a792f888e07 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Sun, 20 Sep 2020 00:24:08 +0900 Subject: [PATCH 08/12] tree-depth converted to uindex_t --- octree/include/pcl/octree/impl/octree_pointcloud.hpp | 8 ++++---- octree/include/pcl/octree/impl/octree_search.hpp | 8 ++++---- octree/include/pcl/octree/octree_pointcloud.h | 8 ++++---- octree/include/pcl/octree/octree_pointcloud_density.h | 2 +- octree/include/pcl/octree/octree_search.h | 8 ++++---- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/octree/include/pcl/octree/impl/octree_pointcloud.hpp b/octree/include/pcl/octree/impl/octree_pointcloud.hpp index 2d16c658708..38fc3346bf7 100644 --- a/octree/include/pcl/octree/impl/octree_pointcloud.hpp +++ b/octree/include/pcl/octree/impl/octree_pointcloud.hpp @@ -859,7 +859,7 @@ template :: genVoxelCenterFromOctreeKey(const OctreeKey& key_arg, - unsigned int tree_depth_arg, + uindex_t tree_depth_arg, PointT& point_arg) const { // generate point for voxel center defined by treedepth (bitLen) and key @@ -888,7 +888,7 @@ template :: genVoxelBoundsFromOctreeKey(const OctreeKey& key_arg, - unsigned int tree_depth_arg, + uindex_t tree_depth_arg, Eigen::Vector3f& min_pt, Eigen::Vector3f& max_pt) const { @@ -920,7 +920,7 @@ template double pcl::octree::OctreePointCloud:: - getVoxelSquaredSideLen(unsigned int tree_depth_arg) const + getVoxelSquaredSideLen(uindex_t tree_depth_arg) const { double side_len; @@ -941,7 +941,7 @@ template double pcl::octree::OctreePointCloud:: - getVoxelSquaredDiameter(unsigned int tree_depth_arg) const + getVoxelSquaredDiameter(uindex_t tree_depth_arg) const { // return the squared side length of the voxel cube as a function of the octree depth return (getVoxelSquaredSideLen(tree_depth_arg) * 3); diff --git a/octree/include/pcl/octree/impl/octree_search.hpp b/octree/include/pcl/octree/impl/octree_search.hpp index 6f7563bad00..b9248d41ccc 100644 --- a/octree/include/pcl/octree/impl/octree_search.hpp +++ b/octree/include/pcl/octree/impl/octree_search.hpp @@ -226,7 +226,7 @@ OctreePointCloudSearch:: uindex_t K, const BranchNode* node, const OctreeKey& key, - unsigned int tree_depth, + uindex_t tree_depth, const double squared_search_radius, std::vector& point_candidates) const { @@ -337,7 +337,7 @@ OctreePointCloudSearch:: const double radiusSquared, const BranchNode* node, const OctreeKey& key, - unsigned int tree_depth, + uindex_t tree_depth, Indices& k_indices, std::vector& k_sqr_distances, uindex_t max_nn) const @@ -423,7 +423,7 @@ OctreePointCloudSearch:: approxNearestSearchRecursive(const PointT& point, const BranchNode* node, const OctreeKey& key, - unsigned int tree_depth, + uindex_t tree_depth, index_t& result_index, float& sqr_distance) { @@ -521,7 +521,7 @@ OctreePointCloudSearch::boxSearchRecur const Eigen::Vector3f& max_pt, const BranchNode* node, const OctreeKey& key, - unsigned int tree_depth, + uindex_t tree_depth, Indices& k_indices) const { // iterate over all children diff --git a/octree/include/pcl/octree/octree_pointcloud.h b/octree/include/pcl/octree/octree_pointcloud.h index 66afc625c41..975eeeaa8bf 100644 --- a/octree/include/pcl/octree/octree_pointcloud.h +++ b/octree/include/pcl/octree/octree_pointcloud.h @@ -365,7 +365,7 @@ class OctreePointCloud : public OctreeT { * \return squared diameter */ double - getVoxelSquaredDiameter(unsigned int tree_depth_arg) const; + getVoxelSquaredDiameter(uindex_t tree_depth_arg) const; /** \brief Calculates the squared diameter of a voxel at leaf depth * \return squared diameter @@ -381,7 +381,7 @@ class OctreePointCloud : public OctreeT { * \return squared voxel cube side length */ double - getVoxelSquaredSideLen(unsigned int tree_depth_arg) const; + getVoxelSquaredSideLen(uindex_t tree_depth_arg) const; /** \brief Calculates the squared voxel cube side length at leaf level * \return squared voxel cube side length @@ -536,7 +536,7 @@ class OctreePointCloud : public OctreeT { */ void genVoxelCenterFromOctreeKey(const OctreeKey& key_arg, - unsigned int tree_depth_arg, + uindex_t tree_depth_arg, PointT& point_arg) const; /** \brief Generate bounds of an octree voxel using octree key and tree depth @@ -548,7 +548,7 @@ class OctreePointCloud : public OctreeT { */ void genVoxelBoundsFromOctreeKey(const OctreeKey& key_arg, - unsigned int tree_depth_arg, + uindex_t tree_depth_arg, Eigen::Vector3f& min_pt, Eigen::Vector3f& max_pt) const; diff --git a/octree/include/pcl/octree/octree_pointcloud_density.h b/octree/include/pcl/octree/octree_pointcloud_density.h index 1083c20a059..35501033697 100644 --- a/octree/include/pcl/octree/octree_pointcloud_density.h +++ b/octree/include/pcl/octree/octree_pointcloud_density.h @@ -129,7 +129,7 @@ class OctreePointCloudDensity * \param[in] point_arg: a point addressing a voxel \return amount of points * that fall within leaf node voxel */ - unsigned int + uindex_t getVoxelDensityAtPoint(const PointT& point_arg) const { uindex_t point_count = 0; diff --git a/octree/include/pcl/octree/octree_search.h b/octree/include/pcl/octree/octree_search.h index df5dffaca9d..8ed045b3189 100644 --- a/octree/include/pcl/octree/octree_search.h +++ b/octree/include/pcl/octree/octree_search.h @@ -388,7 +388,7 @@ class OctreePointCloudSearch const double radiusSquared, const BranchNode* node, const OctreeKey& key, - unsigned int tree_depth, + uindex_t tree_depth, Indices& k_indices, std::vector& k_sqr_distances, uindex_t max_nn) const; @@ -410,7 +410,7 @@ class OctreePointCloudSearch uindex_t K, const BranchNode* node, const OctreeKey& key, - unsigned int tree_depth, + uindex_t tree_depth, const double squared_search_radius, std::vector& point_candidates) const; @@ -427,7 +427,7 @@ class OctreePointCloudSearch approxNearestSearchRecursive(const PointT& point, const BranchNode* node, const OctreeKey& key, - unsigned int tree_depth, + uindex_t tree_depth, index_t& result_index, float& sqr_distance); @@ -476,7 +476,7 @@ class OctreePointCloudSearch const Eigen::Vector3f& max_pt, const BranchNode* node, const OctreeKey& key, - unsigned int tree_depth, + uindex_t tree_depth, Indices& k_indices) const; /** \brief Recursively search the tree for all intersected leaf nodes and return a From 0b84314223195cc1864f241c296c26fbad96c029 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Fri, 9 Oct 2020 19:26:49 +0900 Subject: [PATCH 09/12] Addressing some of the review comments --- octree/include/pcl/octree/impl/octree_pointcloud.hpp | 4 ++-- .../pcl/octree/impl/octree_pointcloud_adjacency.hpp | 4 ++-- octree/include/pcl/octree/impl/octree_search.hpp | 4 ++-- octree/include/pcl/octree/octree_container.h | 10 +++++----- octree/include/pcl/octree/octree_pointcloud.h | 2 +- .../pcl/octree/octree_pointcloud_adjacency_container.h | 4 ++-- .../pcl/octree/octree_pointcloud_changedetector.h | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/octree/include/pcl/octree/impl/octree_pointcloud.hpp b/octree/include/pcl/octree/impl/octree_pointcloud.hpp index 38fc3346bf7..e89f2d4522b 100644 --- a/octree/include/pcl/octree/impl/octree_pointcloud.hpp +++ b/octree/include/pcl/octree/impl/octree_pointcloud.hpp @@ -265,7 +265,7 @@ template -pcl::index_t +pcl::uindex_t pcl::octree::OctreePointCloud:: getApproxIntersectedVoxelCentersBySegment(const Eigen::Vector3f& origin, const Eigen::Vector3f& end, @@ -320,7 +320,7 @@ pcl::octree::OctreePointCloud voxel_center_list.push_back(center); } - return (static_cast(voxel_center_list.size())); + return (static_cast(voxel_center_list.size())); } ////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp b/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp index 3bcaf1ce147..d5e4cc05fa9 100644 --- a/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp +++ b/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp @@ -288,13 +288,13 @@ pcl::octree::OctreePointCloudAdjacency direction.normalize(); float precision = 1.0f; const float step_size = static_cast(resolution_) * precision; - const auto nsteps = std::max(1, norm / step_size); + const auto nsteps = std::max(1, norm / step_size); OctreeKey prev_key = key; // Walk along the line segment with small steps. Eigen::Vector3f p = leaf_centroid; PointT octree_p; - for (uindex_t i = 0; i < nsteps; ++i) { + for (std::size_t i = 0; i < nsteps; ++i) { // Start at the leaf voxel, and move back towards sensor. p += (direction * step_size); diff --git a/octree/include/pcl/octree/impl/octree_search.hpp b/octree/include/pcl/octree/impl/octree_search.hpp index b9248d41ccc..61fd51738ef 100644 --- a/octree/include/pcl/octree/impl/octree_search.hpp +++ b/octree/include/pcl/octree/impl/octree_search.hpp @@ -107,12 +107,12 @@ OctreePointCloudSearch::nearestKSearch getKNearestNeighborRecursive( p_q, k, this->root_node_, key, 1, smallest_dist, point_candidates); - index_t result_count = static_cast(point_candidates.size()); + const auto result_count = static_cast(point_candidates.size()); k_indices.resize(result_count); k_sqr_distances.resize(result_count); - for (index_t i = 0; i < result_count; ++i) { + for (uindex_t i = 0; i < result_count; ++i) { k_indices[i] = point_candidates[i].point_idx_; k_sqr_distances[i] = point_candidates[i].point_distance_; } diff --git a/octree/include/pcl/octree/octree_container.h b/octree/include/pcl/octree/octree_container.h index 049ca9855c2..f520cbcda86 100644 --- a/octree/include/pcl/octree/octree_container.h +++ b/octree/include/pcl/octree/octree_container.h @@ -76,7 +76,7 @@ class OctreeContainerBase { /** \brief Pure abstract method to get size of container (number of indices) * \return number of points/indices stored in leaf node container. */ - virtual index_t + virtual uindex_t getSize() const { return 0u; @@ -127,7 +127,7 @@ class OctreeContainerEmpty : public OctreeContainerBase { /** \brief Abstract get size of container (number of DataT objects) * \return number of DataT elements in leaf node container. */ - index_t + uindex_t getSize() const override { return 0; @@ -225,7 +225,7 @@ class OctreeContainerPointIndex : public OctreeContainerBase { /** \brief Get size of container (number of DataT objects) * \return number of DataT elements in leaf node container. */ - index_t + uindex_t getSize() const override { return data_ != static_cast(-1) ? 0 : 1; @@ -314,10 +314,10 @@ class OctreeContainerPointIndices : public OctreeContainerBase { /** \brief Get size of container (number of indices) * \return number of point indices in container. */ - index_t + uindex_t getSize() const override { - return static_cast(leafDataTVector_.size()); + return static_cast(leafDataTVector_.size()); } /** \brief Reset leaf node. Clear DataT vector.*/ diff --git a/octree/include/pcl/octree/octree_pointcloud.h b/octree/include/pcl/octree/octree_pointcloud.h index 975eeeaa8bf..6cd91a167f2 100644 --- a/octree/include/pcl/octree/octree_pointcloud.h +++ b/octree/include/pcl/octree/octree_pointcloud.h @@ -279,7 +279,7 @@ class OctreePointCloud : public OctreeT { * octree_resolution x precision * \return number of intersected voxels */ - index_t + uindex_t getApproxIntersectedVoxelCentersBySegment(const Eigen::Vector3f& origin, const Eigen::Vector3f& end, AlignedPointTVector& voxel_center_list, diff --git a/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h b/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h index a5bc2a2a25b..6cff9dad137 100644 --- a/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h +++ b/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h @@ -119,10 +119,10 @@ class OctreePointCloudAdjacencyContainer : public OctreeContainerBase { /** \brief virtual method to get size of container * \return number of points added to leaf node container. */ - index_t + uindex_t getSize() const override { - return static_cast(num_points_); + return num_points_; } protected: diff --git a/octree/include/pcl/octree/octree_pointcloud_changedetector.h b/octree/include/pcl/octree/octree_pointcloud_changedetector.h index b240fb8b53d..c8ddadf3185 100644 --- a/octree/include/pcl/octree/octree_pointcloud_changedetector.h +++ b/octree/include/pcl/octree/octree_pointcloud_changedetector.h @@ -92,14 +92,14 @@ class OctreePointCloudChangeDetector */ std::size_t getPointIndicesFromNewVoxels(Indices& indicesVector_arg, - const index_t minPointsPerLeaf_arg = 0) + const uindex_t minPointsPerLeaf_arg = 0) { std::vector leaf_containers; this->serializeNewLeafs(leaf_containers); for (const auto& leaf_container : leaf_containers) { - if (static_cast(leaf_container->getSize()) >= minPointsPerLeaf_arg) + if (static_cast(leaf_container->getSize()) >= minPointsPerLeaf_arg) leaf_container->getPointIndices(indicesVector_arg); } From 7eb38886c4281e45398865d4f21350e5974d890b Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Fri, 19 Feb 2021 00:44:50 +0900 Subject: [PATCH 10/12] Switching on octree on the CI to confirm --- .ci/azure-pipelines/build/ubuntu_indices.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/azure-pipelines/build/ubuntu_indices.yaml b/.ci/azure-pipelines/build/ubuntu_indices.yaml index 28f8340db43..bbdc900ffa6 100644 --- a/.ci/azure-pipelines/build/ubuntu_indices.yaml +++ b/.ci/azure-pipelines/build/ubuntu_indices.yaml @@ -14,7 +14,7 @@ steps: -DBUILD_tools=OFF \ -DBUILD_kdtree=OFF \ -DBUILD_ml=OFF \ - -DBUILD_octree=OFF \ + -DBUILD_octree=ON \ -DBUILD_global_tests=ON # Temporary fix to ensure no tests are skipped cmake $(Build.SourcesDirectory) From 45c2b131be8984a484ca141db221e1257de29b61 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Sat, 20 Feb 2021 13:27:40 +0900 Subject: [PATCH 11/12] Making incoming index unsigned --- .../pcl/octree/impl/octree_pointcloud.hpp | 6 +++--- .../impl/octree_pointcloud_adjacency.hpp | 2 +- .../include/pcl/octree/impl/octree_search.hpp | 8 ++++---- octree/include/pcl/octree/octree_pointcloud.h | 6 +++--- .../pcl/octree/octree_pointcloud_adjacency.h | 2 +- .../octree/octree_pointcloud_voxelcentroid.h | 2 +- octree/include/pcl/octree/octree_search.h | 18 +++++++++--------- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/octree/include/pcl/octree/impl/octree_pointcloud.hpp b/octree/include/pcl/octree/impl/octree_pointcloud.hpp index e89f2d4522b..9326b64af43 100644 --- a/octree/include/pcl/octree/impl/octree_pointcloud.hpp +++ b/octree/include/pcl/octree/impl/octree_pointcloud.hpp @@ -105,7 +105,7 @@ template void pcl::octree::OctreePointCloud:: - addPointFromCloud(const index_t point_idx_arg, IndicesPtr indices_arg) + addPointFromCloud(const uindex_t point_idx_arg, IndicesPtr indices_arg) { this->addPointIdx(point_idx_arg); if (indices_arg) @@ -652,7 +652,7 @@ template void pcl::octree::OctreePointCloud:: - addPointIdx(const index_t point_idx_arg) + addPointIdx(const uindex_t point_idx_arg) { OctreeKey key; @@ -700,7 +700,7 @@ template const PointT& pcl::octree::OctreePointCloud:: - getPointByIndex(const index_t index_arg) const + getPointByIndex(const uindex_t index_arg) const { // retrieve point from input cloud assert(index_arg < input_->size()); diff --git a/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp b/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp index d5e4cc05fa9..57590745684 100644 --- a/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp +++ b/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp @@ -147,7 +147,7 @@ pcl::octree::OctreePointCloudAdjacency template void pcl::octree::OctreePointCloudAdjacency:: - addPointIdx(const index_t pointIdx_arg) + addPointIdx(const uindex_t pointIdx_arg) { OctreeKey key; diff --git a/octree/include/pcl/octree/impl/octree_search.hpp b/octree/include/pcl/octree/impl/octree_search.hpp index 61fd51738ef..d385e185c70 100644 --- a/octree/include/pcl/octree/impl/octree_search.hpp +++ b/octree/include/pcl/octree/impl/octree_search.hpp @@ -71,7 +71,7 @@ OctreePointCloudSearch::voxelSearch( template bool OctreePointCloudSearch::voxelSearch( - const index_t index, Indices& point_idx_data) + const uindex_t index, Indices& point_idx_data) { const PointT search_point = this->getPointByIndex(index); return (this->voxelSearch(search_point, point_idx_data)); @@ -123,7 +123,7 @@ OctreePointCloudSearch::nearestKSearch template uindex_t OctreePointCloudSearch::nearestKSearch( - index_t index, uindex_t k, Indices& k_indices, std::vector& k_sqr_distances) + uindex_t index, uindex_t k, Indices& k_indices, std::vector& k_sqr_distances) { const PointT search_point = this->getPointByIndex(index); return (nearestKSearch(search_point, k, k_indices, k_sqr_distances)); @@ -150,7 +150,7 @@ OctreePointCloudSearch::approxNearestS template void OctreePointCloudSearch::approxNearestSearch( - index_t query_index, index_t& result_index, float& sqr_distance) + uindex_t query_index, index_t& result_index, float& sqr_distance) { const PointT search_point = this->getPointByIndex(query_index); @@ -189,7 +189,7 @@ OctreePointCloudSearch::radiusSearch( template uindex_t OctreePointCloudSearch::radiusSearch( - index_t index, + uindex_t index, const double radius, Indices& k_indices, std::vector& k_sqr_distances, diff --git a/octree/include/pcl/octree/octree_pointcloud.h b/octree/include/pcl/octree/octree_pointcloud.h index 6cd91a167f2..be4df0fc1b4 100644 --- a/octree/include/pcl/octree/octree_pointcloud.h +++ b/octree/include/pcl/octree/octree_pointcloud.h @@ -200,7 +200,7 @@ class OctreePointCloud : public OctreeT { * setInputCloud) */ void - addPointFromCloud(index_t point_idx_arg, IndicesPtr indices_arg); + addPointFromCloud(uindex_t point_idx_arg, IndicesPtr indices_arg); /** \brief Add point simultaneously to octree and input point cloud. * \param[in] point_arg point to be added @@ -428,7 +428,7 @@ class OctreePointCloud : public OctreeT { * \a setInputCloud to be added */ virtual void - addPointIdx(index_t point_idx_arg); + addPointIdx(uindex_t point_idx_arg); /** \brief Add point at index from input pointcloud dataset to octree * \param[in] leaf_node to be expanded @@ -448,7 +448,7 @@ class OctreePointCloud : public OctreeT { * \return PointT from input pointcloud dataset */ const PointT& - getPointByIndex(index_t index_arg) const; + getPointByIndex(uindex_t index_arg) const; /** \brief Find octree leaf node at a given point * \param[in] point_arg query point diff --git a/octree/include/pcl/octree/octree_pointcloud_adjacency.h b/octree/include/pcl/octree/octree_pointcloud_adjacency.h index 8b93c9b71d3..0d4ea118478 100644 --- a/octree/include/pcl/octree/octree_pointcloud_adjacency.h +++ b/octree/include/pcl/octree/octree_pointcloud_adjacency.h @@ -195,7 +195,7 @@ class OctreePointCloudAdjacency * \note This virtual implementation allows the use of a transform function to compute * keys. */ void - addPointIdx(index_t point_idx_arg) override; + addPointIdx(uindex_t point_idx_arg) override; /** \brief Fills in the neighbors fields for new voxels. * diff --git a/octree/include/pcl/octree/octree_pointcloud_voxelcentroid.h b/octree/include/pcl/octree/octree_pointcloud_voxelcentroid.h index 4c8973f9019..a31113363b8 100644 --- a/octree/include/pcl/octree/octree_pointcloud_voxelcentroid.h +++ b/octree/include/pcl/octree/octree_pointcloud_voxelcentroid.h @@ -156,7 +156,7 @@ class OctreePointCloudVoxelCentroid * \param pointIdx_arg */ void - addPointIdx(const index_t pointIdx_arg) override + addPointIdx(const uindex_t pointIdx_arg) override { OctreeKey key; diff --git a/octree/include/pcl/octree/octree_search.h b/octree/include/pcl/octree/octree_search.h index 8ed045b3189..ed29fb2d8e5 100644 --- a/octree/include/pcl/octree/octree_search.h +++ b/octree/include/pcl/octree/octree_search.h @@ -100,7 +100,7 @@ class OctreePointCloudSearch * \return "true" if leaf node exist; "false" otherwise */ bool - voxelSearch(const index_t index, Indices& point_idx_data); + voxelSearch(uindex_t index, Indices& point_idx_data); /** \brief Search for k-nearest neighbors at the query point. * \param[in] cloud the point cloud data @@ -114,7 +114,7 @@ class OctreePointCloudSearch */ inline uindex_t nearestKSearch(const PointCloud& cloud, - index_t index, + uindex_t index, uindex_t k, Indices& k_indices, std::vector& k_sqr_distances) @@ -149,7 +149,7 @@ class OctreePointCloudSearch * \return number of neighbors found */ uindex_t - nearestKSearch(index_t index, + nearestKSearch(uindex_t index, uindex_t k, Indices& k_indices, std::vector& k_sqr_distances); @@ -163,7 +163,7 @@ class OctreePointCloudSearch */ inline void approxNearestSearch(const PointCloud& cloud, - index_t query_index, + uindex_t query_index, index_t& result_index, float& sqr_distance) { @@ -187,7 +187,7 @@ class OctreePointCloudSearch * \return number of neighbors found */ void - approxNearestSearch(index_t query_index, index_t& result_index, float& sqr_distance); + approxNearestSearch(uindex_t query_index, index_t& result_index, float& sqr_distance); /** \brief Search for all neighbors of query point that are within a given radius. * \param[in] cloud the point cloud data @@ -201,7 +201,7 @@ class OctreePointCloudSearch */ uindex_t radiusSearch(const PointCloud& cloud, - index_t index, + uindex_t index, double radius, Indices& k_indices, std::vector& k_sqr_distances, @@ -238,7 +238,7 @@ class OctreePointCloudSearch * \return number of neighbors found in radius */ uindex_t - radiusSearch(index_t index, + radiusSearch(uindex_t index, const double radius, Indices& k_indices, std::vector& k_sqr_distances, @@ -341,7 +341,7 @@ class OctreePointCloudSearch * \param[in] point_idx index for a dataset point given by \a setInputCloud * \param[in] point_distance distance of query point to voxel center */ - prioPointQueueEntry(index_t point_idx, float point_distance) + prioPointQueueEntry(uindex_t point_idx, float point_distance) : point_idx_(point_idx), point_distance_(point_distance) {} @@ -355,7 +355,7 @@ class OctreePointCloudSearch } /** \brief Index representing a point in the dataset given by \a setInputCloud. */ - index_t point_idx_; + uindex_t point_idx_; /** \brief Distance to query point. */ float point_distance_; From 3c0a163b74202ebbe599013d43dad3273a850547 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Fri, 19 Feb 2021 03:46:27 +0900 Subject: [PATCH 12/12] Working on IO and Stereo modules --- .ci/azure-pipelines/build/ubuntu_indices.yaml | 3 +- io/include/pcl/compression/color_coding.h | 43 +++++++++---------- .../octree_pointcloud_compression.h | 2 +- io/include/pcl/compression/point_coding.h | 13 +++--- .../pcl/octree/impl/octree_iterator.hpp | 3 +- test/octree/test_octree.cpp | 6 +-- 6 files changed, 33 insertions(+), 37 deletions(-) diff --git a/.ci/azure-pipelines/build/ubuntu_indices.yaml b/.ci/azure-pipelines/build/ubuntu_indices.yaml index bbdc900ffa6..07463d6dca0 100644 --- a/.ci/azure-pipelines/build/ubuntu_indices.yaml +++ b/.ci/azure-pipelines/build/ubuntu_indices.yaml @@ -11,10 +11,11 @@ steps: -DPCL_INDEX_SIGNED=$INDEX_SIGNED \ -DPCL_INDEX_SIZE=$INDEX_SIZE \ -DBUILD_geometry=OFF \ + -DBUILD_io=OFF \ -DBUILD_tools=OFF \ -DBUILD_kdtree=OFF \ -DBUILD_ml=OFF \ - -DBUILD_octree=ON \ + -DBUILD_stereo=OFF \ -DBUILD_global_tests=ON # Temporary fix to ensure no tests are skipped cmake $(Build.SourcesDirectory) diff --git a/io/include/pcl/compression/color_coding.h b/io/include/pcl/compression/color_coding.h index af0e6414df5..92bb9d88e72 100644 --- a/io/include/pcl/compression/color_coding.h +++ b/io/include/pcl/compression/color_coding.h @@ -157,16 +157,14 @@ class ColorCoding void encodeAverageOfPoints (const Indices& indexVector_arg, unsigned char rgba_offset_arg, PointCloudConstPtr inputCloud_arg) { - unsigned int avgRed = 0; - unsigned int avgGreen = 0; - unsigned int avgBlue = 0; + uindex_t avgRed = 0; + uindex_t avgGreen = 0; + uindex_t avgBlue = 0; // iterate over points - std::size_t len = indexVector_arg.size (); - for (std::size_t i = 0; i < len; i++) + for (const auto& idx: indexVector_arg) { // get color information from points - const int& idx = indexVector_arg[i]; const char* idxPointPtr = reinterpret_cast (&(*inputCloud_arg)[idx]); const int& colorInt = *reinterpret_cast (idxPointPtr+rgba_offset_arg); @@ -177,12 +175,13 @@ class ColorCoding } + const uindex_t len = static_cast (indexVector_arg.size()); // calculated average color information if (len > 1) { - avgRed /= static_cast (len); - avgGreen /= static_cast (len); - avgBlue /= static_cast (len); + avgRed /= len; + avgGreen /= len; + avgBlue /= len; } // remove least significant bits @@ -204,19 +203,17 @@ class ColorCoding void encodePoints (const Indices& indexVector_arg, unsigned char rgba_offset_arg, PointCloudConstPtr inputCloud_arg) { - unsigned int avgRed; - unsigned int avgGreen; - unsigned int avgBlue; + uindex_t avgRed; + uindex_t avgGreen; + uindex_t avgBlue; // initialize avgRed = avgGreen = avgBlue = 0; // iterate over points - std::size_t len = indexVector_arg.size (); - for (std::size_t i = 0; i < len; i++) + for (const auto& idx: indexVector_arg) { // get color information from point - const int& idx = indexVector_arg[i]; const char* idxPointPtr = reinterpret_cast (&(*inputCloud_arg)[idx]); const int& colorInt = *reinterpret_cast (idxPointPtr+rgba_offset_arg); @@ -227,6 +224,7 @@ class ColorCoding } + const uindex_t len = static_cast (indexVector_arg.size()); if (len > 1) { unsigned char diffRed; @@ -234,14 +232,13 @@ class ColorCoding unsigned char diffBlue; // calculated average color information - avgRed /= static_cast (len); - avgGreen /= static_cast (len); - avgBlue /= static_cast (len); + avgRed /= len; + avgGreen /= len; + avgBlue /= len; // iterate over points for differential encoding - for (std::size_t i = 0; i < len; i++) + for (const auto& idx: indexVector_arg) { - const int& idx = indexVector_arg[i]; const char* idxPointPtr = reinterpret_cast (&(*inputCloud_arg)[idx]); const int& colorInt = *reinterpret_cast (idxPointPtr+rgba_offset_arg); @@ -281,12 +278,12 @@ class ColorCoding * \param rgba_offset_arg offset to color information */ void - decodePoints (PointCloudPtr outputCloud_arg, std::size_t beginIdx_arg, std::size_t endIdx_arg, unsigned char rgba_offset_arg) + decodePoints (PointCloudPtr outputCloud_arg, uindex_t beginIdx_arg, uindex_t endIdx_arg, unsigned char rgba_offset_arg) { assert (beginIdx_arg <= endIdx_arg); // amount of points to be decoded - unsigned int pointCount = static_cast (endIdx_arg - beginIdx_arg); + const index_t pointCount = endIdx_arg - beginIdx_arg; // get averaged color information for current voxel unsigned char avgRed = *(pointAvgColorDataVector_Iterator_++); @@ -299,7 +296,7 @@ class ColorCoding avgBlue = static_cast (avgBlue << colorBitReduction_); // iterate over points - for (std::size_t i = 0; i < pointCount; i++) + for (index_t i = 0; i < pointCount; i++) { unsigned int colorInt; if (pointCount > 1) diff --git a/io/include/pcl/compression/octree_pointcloud_compression.h b/io/include/pcl/compression/octree_pointcloud_compression.h index 4a742179d91..ad1ef83a3d9 100644 --- a/io/include/pcl/compression/octree_pointcloud_compression.h +++ b/io/include/pcl/compression/octree_pointcloud_compression.h @@ -158,7 +158,7 @@ namespace pcl * \param[in] pointIdx_arg the index representing the point in the dataset given by \a setInputCloud to be added */ void - addPointIdx (const index_t pointIdx_arg) override + addPointIdx (const uindex_t pointIdx_arg) override { ++object_count_; OctreePointCloud::addPointIdx(pointIdx_arg); diff --git a/io/include/pcl/compression/point_coding.h b/io/include/pcl/compression/point_coding.h index d10eb23c44c..79db3a0d412 100644 --- a/io/include/pcl/compression/point_coding.h +++ b/io/include/pcl/compression/point_coding.h @@ -129,15 +129,12 @@ class PointCoding encodePoints (const Indices& indexVector_arg, const double* referencePoint_arg, PointCloudConstPtr inputCloud_arg) { - std::size_t len = indexVector_arg.size (); - // iterate over points within current voxel - for (std::size_t i = 0; i < len; i++) + for (const auto& idx: indexVector_arg) { unsigned char diffX, diffY, diffZ; // retrieve point from cloud - const int& idx = indexVector_arg[i]; const PointT& idxPoint = (*inputCloud_arg)[idx]; // differentially encode point coordinates and truncate overflow @@ -159,15 +156,15 @@ class PointCoding * \param endIdx_arg index indicating last point to be assigned with color information */ void - decodePoints (PointCloudPtr outputCloud_arg, const double* referencePoint_arg, std::size_t beginIdx_arg, - std::size_t endIdx_arg) + decodePoints (PointCloudPtr outputCloud_arg, const double* referencePoint_arg, uindex_t beginIdx_arg, + uindex_t endIdx_arg) { assert (beginIdx_arg <= endIdx_arg); - unsigned int pointCount = static_cast (endIdx_arg - beginIdx_arg); + const uindex_t pointCount = endIdx_arg - beginIdx_arg; // iterate over points within current voxel - for (std::size_t i = 0; i < pointCount; i++) + for (uindex_t i = 0; i < pointCount; i++) { // retrieve differential point information const unsigned char& diffX = static_cast (*(pointDiffDataVectorIterator_++)); diff --git a/octree/include/pcl/octree/impl/octree_iterator.hpp b/octree/include/pcl/octree/impl/octree_iterator.hpp index 6a394ab1545..1398cf5d2a6 100644 --- a/octree/include/pcl/octree/impl/octree_iterator.hpp +++ b/octree/include/pcl/octree/impl/octree_iterator.hpp @@ -257,7 +257,8 @@ OctreeBreadthFirstIterator::operator++() ////////////////////////////////////////////////////////////////////////////////////////////// template -OctreeFixedDepthIterator::OctreeFixedDepthIterator() : fixed_depth_(0u) +OctreeFixedDepthIterator::OctreeFixedDepthIterator() +: OctreeBreadthFirstIterator(nullptr, 0), fixed_depth_(0u) {} ////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/test/octree/test_octree.cpp b/test/octree/test_octree.cpp index b2c7e579a93..f04115fa373 100644 --- a/test/octree/test_octree.cpp +++ b/test/octree/test_octree.cpp @@ -797,7 +797,7 @@ TEST (PCL, Octree_Pointcloud_Test) auto current = pointIdxVec.cbegin (); while (current != pointIdxVec.cend ()) { - if (*current == static_cast (i)) + if (*current == static_cast (i)) { bIdxFound = true; break; @@ -1325,7 +1325,7 @@ TEST(PCL, Octree_Pointcloud_Approx_Nearest_Neighbour_Search) // brute force search double BFdistance = std::numeric_limits::max (); - int BFindex = 0; + pcl::index_t BFindex = 0; for (std::size_t i = 0; i < cloudIn->size (); i++) { @@ -1335,7 +1335,7 @@ TEST(PCL, Octree_Pointcloud_Approx_Nearest_Neighbour_Search) if (pointDist < BFdistance) { - BFindex = static_cast (i); + BFindex = static_cast (i); BFdistance = pointDist; }