2014-05-13 18:06:01 +00:00
|
|
|
#ifndef slic3r_MotionPlanner_hpp_
|
|
|
|
#define slic3r_MotionPlanner_hpp_
|
|
|
|
|
2015-12-07 23:39:54 +00:00
|
|
|
#include "libslic3r.h"
|
2014-05-13 18:06:01 +00:00
|
|
|
#include "ClipperUtils.hpp"
|
|
|
|
#include "ExPolygonCollection.hpp"
|
|
|
|
#include "Polyline.hpp"
|
2014-05-28 08:16:58 +00:00
|
|
|
#include <map>
|
|
|
|
#include <utility>
|
2014-05-13 18:06:01 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#define MP_INNER_MARGIN scale_(1.0)
|
|
|
|
#define MP_OUTER_MARGIN scale_(2.0)
|
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
|
2014-05-28 08:16:58 +00:00
|
|
|
class MotionPlannerGraph;
|
|
|
|
|
2014-05-13 18:06:01 +00:00
|
|
|
class MotionPlanner
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MotionPlanner(const ExPolygons &islands);
|
|
|
|
~MotionPlanner();
|
2015-01-19 17:53:04 +00:00
|
|
|
Polyline shortest_path(const Point &from, const Point &to);
|
2014-10-14 22:59:26 +00:00
|
|
|
size_t islands_count() const;
|
2014-05-13 18:06:01 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
ExPolygons islands;
|
|
|
|
bool initialized;
|
|
|
|
ExPolygon outer;
|
|
|
|
ExPolygonCollections inner;
|
2014-05-28 08:16:58 +00:00
|
|
|
std::vector<MotionPlannerGraph*> graphs;
|
2014-05-13 18:06:01 +00:00
|
|
|
|
|
|
|
void initialize();
|
2014-05-28 08:16:58 +00:00
|
|
|
MotionPlannerGraph* init_graph(int island_idx);
|
2015-11-04 19:48:44 +00:00
|
|
|
ExPolygonCollection get_env(int island_idx) const;
|
2015-01-06 19:52:36 +00:00
|
|
|
Point nearest_env_point(const ExPolygonCollection &env, const Point &from, const Point &to) const;
|
2014-05-28 08:16:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class MotionPlannerGraph
|
|
|
|
{
|
2015-01-06 19:52:36 +00:00
|
|
|
friend class MotionPlanner;
|
|
|
|
|
2014-05-28 08:16:58 +00:00
|
|
|
private:
|
2015-11-04 19:48:44 +00:00
|
|
|
typedef int node_t;
|
2014-05-28 08:16:58 +00:00
|
|
|
typedef double weight_t;
|
|
|
|
struct neighbor {
|
|
|
|
node_t target;
|
|
|
|
weight_t weight;
|
|
|
|
neighbor(node_t arg_target, weight_t arg_weight)
|
|
|
|
: target(arg_target), weight(arg_weight) { }
|
|
|
|
};
|
|
|
|
typedef std::vector< std::vector<neighbor> > adjacency_list_t;
|
|
|
|
adjacency_list_t adjacency_list;
|
|
|
|
|
|
|
|
public:
|
|
|
|
Points nodes;
|
|
|
|
//std::map<std::pair<size_t,size_t>, double> edges;
|
|
|
|
void add_edge(size_t from, size_t to, double weight);
|
|
|
|
size_t find_node(const Point &point) const;
|
2015-01-19 17:53:04 +00:00
|
|
|
Polyline shortest_path(size_t from, size_t to);
|
2014-05-13 18:06:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|