Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix problems in octree search functions when using dynamic depth #4657

Merged
merged 3 commits into from
Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions octree/include/pcl/octree/impl/octree_search.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
child_node = search_heap.back().node;
new_key = search_heap.back().key;

if (tree_depth < this->octree_depth_) {
if (child_node->getNodeType() == BRANCH_NODE) {
// we have not reached maximum tree depth
smallest_squared_dist =
getKNearestNeighborRecursive(point,
Expand Down Expand Up @@ -373,7 +373,7 @@ OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
voxel_squared_diameter / 4.0 + radiusSquared +
sqrt(voxel_squared_diameter * radiusSquared)) {

if (tree_depth < this->octree_depth_) {
if (child_node->getNodeType() == BRANCH_NODE) {
// we have not reached maximum tree depth
getNeighborsWithinRadiusRecursive(point,
radiusSquared,
Expand Down Expand Up @@ -468,7 +468,7 @@ OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::

child_node = this->getBranchChildPtr(*node, min_child_idx);

if (tree_depth < this->octree_depth_) {
if (child_node->getNodeType() == BRANCH_NODE) {
// we have not reached maximum tree depth
approxNearestSearchRecursive(point,
static_cast<const BranchNode*>(child_node),
Expand All @@ -483,7 +483,7 @@ OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::

const LeafNode* child_leaf = static_cast<const LeafNode*>(child_node);

double smallest_squared_dist = std::numeric_limits<double>::max();
float smallest_squared_dist = std::numeric_limits<float>::max();

// decode leaf node into decoded_point_vector
(**child_leaf).getPointIndices(decoded_point_vector);
Expand All @@ -493,15 +493,15 @@ OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::
const PointT& candidate_point = this->getPointByIndex(index);

// calculate point distance to search point
double squared_dist = pointSquaredDist(candidate_point, point);
float squared_dist = pointSquaredDist(candidate_point, point);

// check if a closer match is found
if (squared_dist >= smallest_squared_dist)
continue;

result_index = index;
smallest_squared_dist = squared_dist;
sqr_distance = static_cast<float>(squared_dist);
sqr_distance = squared_dist;
}
}
}
Expand Down Expand Up @@ -552,7 +552,7 @@ OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::boxSearchRecur
(lower_voxel_corner(1) > max_pt(1)) || (min_pt(1) > upper_voxel_corner(1)) ||
(lower_voxel_corner(2) > max_pt(2)) || (min_pt(2) > upper_voxel_corner(2)))) {

if (tree_depth < this->octree_depth_) {
if (child_node->getNodeType() == BRANCH_NODE) {
// we have not reached maximum tree depth
boxSearchRecursive(min_pt,
max_pt,
Expand Down
Loading