mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-06-28 06:30:32 +00:00
ENH: add tool order function
1.Use min cost max flow to solve the tool order jira:NEW Signed-off-by: xun.zhang <xun.zhang@bambulab.com> Change-Id: I909845039b67c7fe3ddd42580ad3f1d71d52262d (cherry picked from commit 0716b8518ef62e0eac7c45de8bafb1458d8f9a8e)
This commit is contained in:
@@ -9,6 +9,36 @@ namespace Slic3r {
|
||||
|
||||
using FlushMatrix = std::vector<std::vector<float>>;
|
||||
|
||||
class MCMF
|
||||
{
|
||||
const int INF = std::numeric_limits<int>::max();
|
||||
struct Edge
|
||||
{
|
||||
int from, to, capacity, cost, flow;
|
||||
Edge(int u, int v, int cap, int cst) : from(u), to(v), capacity(cap), cost(cst), flow(0) {}
|
||||
};
|
||||
|
||||
public:
|
||||
MCMF(const FlushMatrix &matrix_, const std::vector<int> &u_nodes, const std::vector<int> &v_nodes);
|
||||
std::vector<int> solve();
|
||||
|
||||
private:
|
||||
void add_edge(int from, int to, int capacity, int cost);
|
||||
bool spfa(int source, int sink);
|
||||
int get_distance(int idx_in_left, int idx_in_right);
|
||||
|
||||
private:
|
||||
FlushMatrix matrix;
|
||||
std::vector<int> l_nodes;
|
||||
std::vector<int> r_nodes;
|
||||
|
||||
int total_nodes;
|
||||
int source_id;
|
||||
int sink_id;
|
||||
|
||||
std::vector<Edge> edges;
|
||||
std::vector<std::vector<int>> adj;
|
||||
};
|
||||
|
||||
std::vector<unsigned int> get_extruders_order(const std::vector<std::vector<float>> &wipe_volumes,
|
||||
const std::vector<unsigned int> &curr_layer_extruders,
|
||||
@@ -24,6 +54,5 @@ int reorder_filaments_for_minimum_flush_volume(const std::vector<unsigned int> &
|
||||
std::optional<std::function<bool(int, std::vector<int> &)>> get_custom_seq,
|
||||
std::vector<std::vector<unsigned int>> *filament_sequences);
|
||||
|
||||
|
||||
}
|
||||
#endif // !TOOL_ORDER_UTILS_HPP
|
||||
|
||||
Reference in New Issue
Block a user