Skip to content

Commit

Permalink
Find mistake: only update search radius after K points are found
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonCampolattaro committed Jul 16, 2020
1 parent f1b2160 commit 1edbc99
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
19 changes: 8 additions & 11 deletions Octree/include/CGAL/Octree.h
Expand Up @@ -522,7 +522,8 @@ class Octree {
});

// Update the distance
largest_radius_squared_found = out.back().second;
if (out.size() == out.capacity())
largest_radius_squared_found = out.back().second;
}
}
}
Expand All @@ -539,15 +540,11 @@ class Octree {
for (int index = 0; index < 8; ++index) {
auto &n = node[index];

// If the node isn't empty
if (0 < std::distance(node.value().begin(), node.value().end())) {

// Find the distance of the node's center
auto node_center_distance = CGAL::squared_distance(p, compute_barycenter_position(n));
// Find the distance of the node's center
auto node_center_distance = CGAL::squared_distance(p, compute_barycenter_position(n));

// Add this node to the list
children_with_distances.emplace_back(index, node_center_distance);
}
// Add this node to the list
children_with_distances.emplace_back(index, node_center_distance);
}

// Sort the children by their distance
Expand All @@ -560,7 +557,7 @@ class Octree {
auto &n = node[child.first.to_ulong()];

// Check whether this node is capable of containing closer points
if (do_intersect(n, Sphere{p, largest_radius_squared_found + 0.1 /*TODO: This is my epsilon*/})) {
if (do_intersect(n, Sphere{p, largest_radius_squared_found + 10 /*TODO: This is my epsilon*/})) {

// Recursive case
largest_radius_squared_found =
Expand All @@ -569,7 +566,7 @@ class Octree {
}
}
}
//out.push_back(p);

return largest_radius_squared_found;
}

Expand Down
4 changes: 2 additions & 2 deletions Octree/test/Octree/test_octree_nearest_neighbour.cpp
Expand Up @@ -174,8 +174,8 @@ int main(void) {

// naive_vs_octree(100);
// naive_vs_octree(1000);
naive_vs_octree(10000);
naive_vs_octree(100000);
// naive_vs_octree(10000);
// naive_vs_octree(100000);

kdtree_vs_octree(100);
// kdtree_vs_octree(1000);
Expand Down

0 comments on commit 1edbc99

Please sign in to comment.