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 bug in OctreePointCloudAdjacency::computeNeighbors() #455

Merged
merged 3 commits into from
Jan 22, 2014
Merged
Changes from 1 commit
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
Next Next commit
Fix a bug in OctreePointCloudAdjacency::computeNeighbors()
The `x`, `y`, and `z` fields of `OctreeKey` are unsigned integers, so
in some cases unsigned integer underflow occurs and the tree is queried
for non-existing leaves with huge keys. Due to the way `findLeaf()` is
implemented, such queries occasionally succeed and return some random
leaves.
  • Loading branch information
taketwo committed Jan 19, 2014
commit 575720c65043b01c24e0a29685d6a5ecc873fae2
15 changes: 12 additions & 3 deletions octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,22 @@ pcl::octree::OctreePointCloudAdjacency<PointT, LeafContainerT, BranchContainerT>

for (int dx = -1; dx <= 1; ++dx)
{
int x = dx + key_arg.x;
if (x < 0 || x > this->max_key_.x)
continue;
neighbor_key.x = static_cast<uint32_t> (x);
for (int dy = -1; dy <= 1; ++dy)
{
int y = dy + key_arg.y;
if (y < 0 || y > this->max_key_.y)
continue;
neighbor_key.y = static_cast<uint32_t> (y);
for (int dz = -1; dz <= 1; ++dz)
{
neighbor_key.x = key_arg.x + dx;
neighbor_key.y = key_arg.y + dy;
neighbor_key.z = key_arg.z + dz;
int z = dz + key_arg.z;
if (z < 0 || z > this->max_key_.z)
continue;
neighbor_key.z = static_cast<uint32_t> (z);
LeafContainerT *neighbor = this->findLeaf (neighbor_key);
if (neighbor)
{
Expand Down