test_jump_point_search.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #include <catch2/catch.hpp>
  2. #include "libslic3r/BoundingBox.hpp"
  3. #include "libslic3r/JumpPointSearch.hpp"
  4. using namespace Slic3r;
  5. TEST_CASE("Test jump point search path finding", "[JumpPointSearch]")
  6. {
  7. Lines obstacles{};
  8. obstacles.push_back(Line(Point::new_scale(0, 0), Point::new_scale(50, 50)));
  9. obstacles.push_back(Line(Point::new_scale(0, 100), Point::new_scale(50, 50)));
  10. obstacles.push_back(Line(Point::new_scale(0, 0), Point::new_scale(100, 0)));
  11. obstacles.push_back(Line(Point::new_scale(0, 100), Point::new_scale(100, 100)));
  12. obstacles.push_back(Line(Point::new_scale(25, -25), Point::new_scale(25, 125)));
  13. JPSPathFinder jps;
  14. jps.add_obstacles(obstacles);
  15. Polyline path = jps.find_path(Point::new_scale(5, 50), Point::new_scale(100, 50));
  16. path = jps.find_path(Point::new_scale(5, 50), Point::new_scale(150, 50));
  17. path = jps.find_path(Point::new_scale(5, 50), Point::new_scale(25, 15));
  18. path = jps.find_path(Point::new_scale(25, 25), Point::new_scale(125, 125));
  19. // SECTION("Output is empty when source is also the destination") {
  20. // bool found = astar::search_route(DummyTracer{}, 0, std::back_inserter(out));
  21. // REQUIRE(out.empty());
  22. // REQUIRE(found);
  23. // }
  24. // SECTION("Return false when there is no route to destination") {
  25. // bool found = astar::search_route(DummyTracer{}, 1, std::back_inserter(out));
  26. // REQUIRE(!found);
  27. // REQUIRE(out.empty());
  28. // }
  29. }