From 694ffd7cb03b8063b705040695cae94403ace5fb Mon Sep 17 00:00:00 2001 From: gianpaolopalma Date: Thu, 28 Apr 2016 10:48:19 +0000 Subject: [PATCH] Bug Fixed in the function doQueryK if the point cloud contains less than k points --- vcg/space/index/kdtree/kdtree.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/vcg/space/index/kdtree/kdtree.h b/vcg/space/index/kdtree/kdtree.h index 4d7e07fe..7f10b012 100755 --- a/vcg/space/index/kdtree/kdtree.h +++ b/vcg/space/index/kdtree/kdtree.h @@ -199,8 +199,7 @@ namespace vcg { { mNeighborQueue.setMaxSize(k); mNeighborQueue.init(); - mNeighborQueue.insert(0xffffffff, std::numeric_limits::max()); - + QueryNode mNodeStack[64]; mNodeStack[0].nodeId = 0; mNodeStack[0].sq = 0.f; @@ -217,9 +216,9 @@ namespace vcg { Node& node = mNodes[qnode.nodeId]; //if the distance is less than the top of the max-heap, it could be one of the k-nearest neighbours - if (qnode.sq < mNeighborQueue.getTopWeight()) - { - //when we arrive to a lef + if (mNeighborQueue.getNofElements() < k || qnode.sq < mNeighborQueue.getTopWeight()) + { + //when we arrive to a leaf if (node.leaf) { --count; //pop of the leaf