Added new query to AABBTree: all primitives (triangles/lines) within radius
This commit is contained in:
parent
b49a2425ca
commit
e02aed31d2
3 changed files with 114 additions and 15 deletions
|
@ -1,3 +1,4 @@
|
|||
#include <algorithm>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <test_utils.hpp>
|
||||
|
||||
|
@ -87,6 +88,25 @@ TEST_CASE("Creating a several 2d lines, testing closest point query", "[AABBIndi
|
|||
REQUIRE(hit_point_out.y() == Approx(0.5));
|
||||
}
|
||||
|
||||
TEST_CASE("Creating a several 2d lines, testing all lines in radius query", "[AABBIndirect]")
|
||||
{
|
||||
std::vector<Linef> lines { };
|
||||
lines.push_back(Linef(Vec2d(0.0, 0.0), Vec2d(10.0, 0.0)));
|
||||
lines.push_back(Linef(Vec2d(-10.0, 10.0), Vec2d(10.0, -10.0)));
|
||||
lines.push_back(Linef(Vec2d(-2.0, -1.0), Vec2d(-2.0, 1.0)));
|
||||
lines.push_back(Linef(Vec2d(-1.0, -1.0), Vec2d(-1.0, -1.0)));
|
||||
lines.push_back(Linef(Vec2d(1.0, 1.0), Vec2d(1.0, 1.0)));
|
||||
|
||||
auto tree = AABBTreeLines::build_aabb_tree_over_indexed_lines(lines);
|
||||
|
||||
auto indices = AABBTreeLines::all_lines_in_radius(lines, tree, Vec2d{1.0,1.0}, 4.0);
|
||||
|
||||
REQUIRE(std::find(indices.begin(),indices.end(), 0) != indices.end());
|
||||
REQUIRE(std::find(indices.begin(),indices.end(), 1) != indices.end());
|
||||
REQUIRE(std::find(indices.begin(),indices.end(), 4) != indices.end());
|
||||
REQUIRE(indices.size() == 3);
|
||||
}
|
||||
|
||||
#if 0
|
||||
#include "libslic3r/EdgeGrid.hpp"
|
||||
#include <iostream>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue