Skip to content

Commit

Permalink
Recursive nearest neighbours now sorts its node queue
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonCampolattaro committed Jul 14, 2020
1 parent 1ce265c commit c5dd606
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions Octree/include/CGAL/Octree.h
Expand Up @@ -48,6 +48,7 @@
#include <queue>
#include <vector>
#include <math.h>
#include <CGAL/squared_distance_3.h>

namespace CGAL {

Expand Down Expand Up @@ -427,7 +428,7 @@ class Octree {
// TODO: Perhaps I should use a purpose-made struct instead of a pair here
std::array<std::pair<FT, typename Node::Index>, 8> nodes_to_visit;

// Add the child nodes to the list
// Add the each of the child nodes to the list
for (int index = 0; index < 3; ++index) {

// Set the indices properly
Expand All @@ -438,19 +439,18 @@ class Octree {

// Empty nodes are considered infinitely far
nodes_to_visit[index].first = std::numeric_limits<FT>::max();
}

else {
} else {

// Find the distance squared between p and the node's center point

nodes_to_visit[index].first = CGAL::squared_distance(p, compute_barycenter_position(node[index]));
}
}




// Sort the nodes by their distance from the point p
// Sort the nodes by their distance
//std::sort(nodes_to_visit.begin(), nodes_to_visit.end());
std::sort(nodes_to_visit.begin(), nodes_to_visit.end(), [](auto &left, auto &right) {
return left.first < right.first;
});

// TODO

Expand Down

0 comments on commit c5dd606

Please sign in to comment.