Files
OrcaSlicer/src/libslic3r/JumpPointSearch.hpp
wenjie.guo d3db1f2537 NEW: path planning algorithm
Astar.hpp, JumpPointSearch.hpp and JumpPointSearch.cpp are from Prusa.

Github: 1793

Signed-off-by: wenjie.guo <wenjie.guo@bambulab.com>

Original Authors:
tamasmeszaros <meszaros.q@gmail.com>,
Pavel Mikus <pavel.mikus.mail@seznam.cz>

Change-Id: I72f68d59bc8bb3b7cc0f37276c10811bca2ac38c
(cherry picked from commit 7a14a6a48af68b6a3d7985bdb9c171aabeb70817)
2023-11-01 09:33:21 +08:00

39 lines
1.1 KiB
C++

#pragma once
#ifndef SRC_LIBSLIC3R_JUMPPOINTSEARCH_HPP_
#define SRC_LIBSLIC3R_JUMPPOINTSEARCH_HPP_
#include "BoundingBox.hpp"
#include "Polygon.hpp"
#include "libslic3r/Layer.hpp"
#include "libslic3r/Point.hpp"
#include "libslic3r/Polyline.hpp"
#include "libslic3r/libslic3r.h"
#include <unordered_map>
#include <unordered_set>
namespace Slic3r {
class JPSPathFinder
{
using Pixel = Point;
std::unordered_set<Pixel, PointHash> inpassable;
coordf_t print_z;
BoundingBox max_search_box;
Lines bed_shape;
const coord_t resolution = scaled(1.5);
Pixel pixelize(const Point &p) { return p / resolution; }
Point unpixelize(const Pixel &p) { return p * resolution; }
public:
JPSPathFinder() = default;
void init_bed_shape(const Points &bed_shape) { this->bed_shape = (to_lines(Polygon{bed_shape})); };
void clear();
void add_obstacles(const Lines &obstacles);
Polyline find_path(const Point &start, const Point &end);
};
} // namespace Slic3r
#endif /* SRC_LIBSLIC3R_JUMPPOINTSEARCH_HPP_ */