mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 16:05:53 +08:00
Added progress to seqential print scheduling.
This commit is contained in:
parent
91a12c4b7c
commit
a651173be1
@ -89,6 +89,7 @@ struct SolverConfiguration
|
|||||||
struct ObjectToPrint
|
struct ObjectToPrint
|
||||||
{
|
{
|
||||||
int id = 0;
|
int id = 0;
|
||||||
|
int previous_id = -1; /* object 'id' will be scheduled right after object 'previous_id' */
|
||||||
coord_t total_height = 0;
|
coord_t total_height = 0;
|
||||||
std::vector<std::pair<coord_t, Slic3r::Polygon>> pgns_at_height;
|
std::vector<std::pair<coord_t, Slic3r::Polygon>> pgns_at_height;
|
||||||
};
|
};
|
||||||
@ -145,12 +146,14 @@ bool check_ScheduledObjectsForSequentialPrintability(const SolverConfiguration
|
|||||||
|
|
||||||
std::vector<ScheduledPlate> schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_configuration,
|
std::vector<ScheduledPlate> schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_configuration,
|
||||||
const PrinterGeometry &printer_geometry,
|
const PrinterGeometry &printer_geometry,
|
||||||
const std::vector<ObjectToPrint> &objects_to_print);
|
const std::vector<ObjectToPrint> &objects_to_print,
|
||||||
|
std::function<void(int)> progress_callback = [](int progress){});
|
||||||
|
|
||||||
void schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_configuration,
|
void schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_configuration,
|
||||||
const PrinterGeometry &printer_geometry,
|
const PrinterGeometry &printer_geometry,
|
||||||
const std::vector<ObjectToPrint> &objects_to_print,
|
const std::vector<ObjectToPrint> &objects_to_print,
|
||||||
std::vector<ScheduledPlate> &scheduled_plates);
|
std::vector<ScheduledPlate> &scheduled_plates,
|
||||||
|
std::function<void(int)> progress_callback = [](int progress){});
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------*/
|
/*----------------------------------------------------------------*/
|
||||||
@ -160,7 +163,8 @@ void schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver
|
|||||||
|
|
||||||
int schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_configuration,
|
int schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_configuration,
|
||||||
const std::vector<ObjectToPrint> &objects_to_print,
|
const std::vector<ObjectToPrint> &objects_to_print,
|
||||||
std::vector<ScheduledPlate> &scheduled_plates);
|
std::vector<ScheduledPlate> &scheduled_plates,
|
||||||
|
std::function<void(int)> progress_callback = [](int progress){});
|
||||||
|
|
||||||
void setup_ExtruderUnreachableZones(const SolverConfiguration &solver_configuration,
|
void setup_ExtruderUnreachableZones(const SolverConfiguration &solver_configuration,
|
||||||
std::vector<std::vector<Slic3r::Polygon> > &convex_unreachable_zones,
|
std::vector<std::vector<Slic3r::Polygon> > &convex_unreachable_zones,
|
||||||
@ -170,7 +174,8 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration
|
|||||||
const std::vector<ObjectToPrint> &objects_to_print,
|
const std::vector<ObjectToPrint> &objects_to_print,
|
||||||
const std::vector<std::vector<Slic3r::Polygon> > &convex_unreachable_zones,
|
const std::vector<std::vector<Slic3r::Polygon> > &convex_unreachable_zones,
|
||||||
const std::vector<std::vector<Slic3r::Polygon> > &box_unreachable_zones,
|
const std::vector<std::vector<Slic3r::Polygon> > &box_unreachable_zones,
|
||||||
std::vector<ScheduledPlate> &scheduled_plates);
|
std::vector<ScheduledPlate> &scheduled_plates,
|
||||||
|
std::function<void(int)> progress_callback = [](int progress){});
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------*/
|
/*----------------------------------------------------------------*/
|
||||||
|
@ -169,7 +169,7 @@ bool check_ScheduledObjectsForSequentialPrintability(const SolverConfiguration
|
|||||||
std::vector<Slic3r::Polygon> polygons;
|
std::vector<Slic3r::Polygon> polygons;
|
||||||
std::vector<std::vector<Slic3r::Polygon> > unreachable_polygons;
|
std::vector<std::vector<Slic3r::Polygon> > unreachable_polygons;
|
||||||
|
|
||||||
map<int, int> flat_index_map;
|
std::map<int, int> flat_index_map;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < objects_to_print.size(); ++i)
|
for (unsigned int i = 0; i < objects_to_print.size(); ++i)
|
||||||
{
|
{
|
||||||
@ -283,14 +283,16 @@ bool check_ScheduledObjectsForSequentialPrintability(const SolverConfiguration
|
|||||||
|
|
||||||
std::vector<ScheduledPlate> schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_configuration,
|
std::vector<ScheduledPlate> schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_configuration,
|
||||||
const PrinterGeometry &printer_geometry,
|
const PrinterGeometry &printer_geometry,
|
||||||
const std::vector<ObjectToPrint> &objects_to_print)
|
const std::vector<ObjectToPrint> &objects_to_print,
|
||||||
|
std::function<void(int)> progress_callback)
|
||||||
{
|
{
|
||||||
std::vector<ScheduledPlate> scheduled_plates;
|
std::vector<ScheduledPlate> scheduled_plates;
|
||||||
|
|
||||||
schedule_ObjectsForSequentialPrint(solver_configuration,
|
schedule_ObjectsForSequentialPrint(solver_configuration,
|
||||||
printer_geometry,
|
printer_geometry,
|
||||||
objects_to_print,
|
objects_to_print,
|
||||||
scheduled_plates);
|
scheduled_plates,
|
||||||
|
progress_callback);
|
||||||
return scheduled_plates;
|
return scheduled_plates;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,7 +300,8 @@ std::vector<ScheduledPlate> schedule_ObjectsForSequentialPrint(const SolverConfi
|
|||||||
void schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_configuration,
|
void schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_configuration,
|
||||||
const PrinterGeometry &printer_geometry,
|
const PrinterGeometry &printer_geometry,
|
||||||
const std::vector<ObjectToPrint> &objects_to_print,
|
const std::vector<ObjectToPrint> &objects_to_print,
|
||||||
std::vector<ScheduledPlate> &scheduled_plates)
|
std::vector<ScheduledPlate> &scheduled_plates,
|
||||||
|
std::function<void(int)> progress_callback)
|
||||||
{
|
{
|
||||||
#ifdef PROFILE
|
#ifdef PROFILE
|
||||||
clock_t start, finish;
|
clock_t start, finish;
|
||||||
@ -314,7 +317,8 @@ void schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver
|
|||||||
std::vector<Slic3r::Polygon> polygons;
|
std::vector<Slic3r::Polygon> polygons;
|
||||||
std::vector<std::vector<Slic3r::Polygon> > unreachable_polygons;
|
std::vector<std::vector<Slic3r::Polygon> > unreachable_polygons;
|
||||||
|
|
||||||
map<int, int> original_index_map;
|
std::map<int, int> original_index_map;
|
||||||
|
std::vector<int> previous_polygons;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
{
|
{
|
||||||
@ -355,6 +359,8 @@ void schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver
|
|||||||
|
|
||||||
unreachable_polygons.push_back(scale_down_unreachable_polygons);
|
unreachable_polygons.push_back(scale_down_unreachable_polygons);
|
||||||
polygons.push_back(scale_down_object_polygon);
|
polygons.push_back(scale_down_object_polygon);
|
||||||
|
|
||||||
|
previous_polygons.push_back(objects_to_print[i].previous_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<int> remaining_polygons;
|
vector<int> remaining_polygons;
|
||||||
@ -376,6 +382,9 @@ void schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int progress_objects_done = 0;
|
||||||
|
int progress_objects_total = objects_to_print.size();
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ScheduledPlate scheduled_plate;
|
ScheduledPlate scheduled_plate;
|
||||||
@ -397,9 +406,13 @@ void schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver
|
|||||||
times_T,
|
times_T,
|
||||||
polygons,
|
polygons,
|
||||||
unreachable_polygons,
|
unreachable_polygons,
|
||||||
|
previous_polygons,
|
||||||
polygon_index_map,
|
polygon_index_map,
|
||||||
decided_polygons,
|
decided_polygons,
|
||||||
remaining_polygons);
|
remaining_polygons,
|
||||||
|
progress_objects_done,
|
||||||
|
progress_objects_total,
|
||||||
|
progress_callback);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
{
|
{
|
||||||
@ -447,6 +460,7 @@ void schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver
|
|||||||
|
|
||||||
scheduled_plate.scheduled_objects.push_back(ScheduledObject(original_index->second, X, Y));
|
scheduled_plate.scheduled_objects.push_back(ScheduledObject(original_index->second, X, Y));
|
||||||
}
|
}
|
||||||
|
progress_objects_done += decided_polygons.size();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -472,19 +486,23 @@ void schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver
|
|||||||
|
|
||||||
vector<Polygon> next_polygons;
|
vector<Polygon> next_polygons;
|
||||||
vector<vector<Polygon> > next_unreachable_polygons;
|
vector<vector<Polygon> > next_unreachable_polygons;
|
||||||
|
vector<int> next_previous_polygons;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < remaining_polygons.size(); ++i)
|
for (unsigned int i = 0; i < remaining_polygons.size(); ++i)
|
||||||
{
|
{
|
||||||
next_polygons.push_back(polygons[remaining_polygons[i]]);
|
next_polygons.push_back(polygons[remaining_polygons[i]]);
|
||||||
next_unreachable_polygons.push_back(unreachable_polygons[remaining_polygons[i]]);
|
next_unreachable_polygons.push_back(unreachable_polygons[remaining_polygons[i]]);
|
||||||
|
next_previous_polygons.push_back(previous_polygons[remaining_polygons[i]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
polygons.clear();
|
polygons.clear();
|
||||||
unreachable_polygons.clear();
|
unreachable_polygons.clear();
|
||||||
|
previous_polygons.clear();
|
||||||
polygon_index_map.clear();
|
polygon_index_map.clear();
|
||||||
|
|
||||||
polygons = next_polygons;
|
polygons = next_polygons;
|
||||||
unreachable_polygons = next_unreachable_polygons;
|
unreachable_polygons = next_unreachable_polygons;
|
||||||
|
previous_polygons = next_previous_polygons;
|
||||||
|
|
||||||
vector<int> next_polygon_index_map;
|
vector<int> next_polygon_index_map;
|
||||||
map<int, int> next_original_index_map;
|
map<int, int> next_original_index_map;
|
||||||
@ -525,7 +543,8 @@ void schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver
|
|||||||
|
|
||||||
int schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_configuration,
|
int schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_configuration,
|
||||||
const std::vector<ObjectToPrint> &objects_to_print,
|
const std::vector<ObjectToPrint> &objects_to_print,
|
||||||
std::vector<ScheduledPlate> &scheduled_plates)
|
std::vector<ScheduledPlate> &scheduled_plates,
|
||||||
|
std::function<void(int)> progress_callback)
|
||||||
{
|
{
|
||||||
#ifdef PROFILE
|
#ifdef PROFILE
|
||||||
clock_t start, finish;
|
clock_t start, finish;
|
||||||
@ -542,6 +561,7 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_
|
|||||||
|
|
||||||
std::vector<Slic3r::Polygon> polygons;
|
std::vector<Slic3r::Polygon> polygons;
|
||||||
std::vector<std::vector<Slic3r::Polygon> > unreachable_polygons;
|
std::vector<std::vector<Slic3r::Polygon> > unreachable_polygons;
|
||||||
|
std::vector<int> previous_polygons;
|
||||||
|
|
||||||
map<int, int> original_index_map;
|
map<int, int> original_index_map;
|
||||||
|
|
||||||
@ -750,6 +770,7 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_
|
|||||||
}
|
}
|
||||||
|
|
||||||
unreachable_polygons.push_back(scale_down_unreachable_polygons);
|
unreachable_polygons.push_back(scale_down_unreachable_polygons);
|
||||||
|
previous_polygons.push_back(objects_to_print[i].previous_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<int> remaining_polygons;
|
vector<int> remaining_polygons;
|
||||||
@ -771,6 +792,9 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int progress_objects_done = 0;
|
||||||
|
int progress_objects_total = objects_to_print.size();
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ScheduledPlate scheduled_plate;
|
ScheduledPlate scheduled_plate;
|
||||||
@ -792,9 +816,13 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_
|
|||||||
times_T,
|
times_T,
|
||||||
polygons,
|
polygons,
|
||||||
unreachable_polygons,
|
unreachable_polygons,
|
||||||
|
previous_polygons,
|
||||||
polygon_index_map,
|
polygon_index_map,
|
||||||
decided_polygons,
|
decided_polygons,
|
||||||
remaining_polygons);
|
remaining_polygons,
|
||||||
|
progress_objects_done,
|
||||||
|
progress_objects_total,
|
||||||
|
progress_callback);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
{
|
{
|
||||||
@ -842,6 +870,7 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_
|
|||||||
|
|
||||||
scheduled_plate.scheduled_objects.push_back(ScheduledObject(original_index->second, X, Y));
|
scheduled_plate.scheduled_objects.push_back(ScheduledObject(original_index->second, X, Y));
|
||||||
}
|
}
|
||||||
|
progress_objects_done += decided_polygons.size();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -866,19 +895,23 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_
|
|||||||
|
|
||||||
vector<Polygon> next_polygons;
|
vector<Polygon> next_polygons;
|
||||||
vector<vector<Polygon> > next_unreachable_polygons;
|
vector<vector<Polygon> > next_unreachable_polygons;
|
||||||
|
vector<int> next_previous_polygons;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < remaining_polygons.size(); ++i)
|
for (unsigned int i = 0; i < remaining_polygons.size(); ++i)
|
||||||
{
|
{
|
||||||
next_polygons.push_back(polygons[remaining_polygons[i]]);
|
next_polygons.push_back(polygons[remaining_polygons[i]]);
|
||||||
next_unreachable_polygons.push_back(unreachable_polygons[remaining_polygons[i]]);
|
next_unreachable_polygons.push_back(unreachable_polygons[remaining_polygons[i]]);
|
||||||
|
next_previous_polygons.push_back(previous_polygons[remaining_polygons[i]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
polygons.clear();
|
polygons.clear();
|
||||||
unreachable_polygons.clear();
|
unreachable_polygons.clear();
|
||||||
|
previous_polygons.clear();
|
||||||
polygon_index_map.clear();
|
polygon_index_map.clear();
|
||||||
|
|
||||||
polygons = next_polygons;
|
polygons = next_polygons;
|
||||||
unreachable_polygons = next_unreachable_polygons;
|
unreachable_polygons = next_unreachable_polygons;
|
||||||
|
previous_polygons = next_previous_polygons;
|
||||||
|
|
||||||
vector<int> next_polygon_index_map;
|
vector<int> next_polygon_index_map;
|
||||||
map<int, int> next_original_index_map;
|
map<int, int> next_original_index_map;
|
||||||
@ -956,7 +989,8 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration
|
|||||||
const std::vector<ObjectToPrint> &objects_to_print,
|
const std::vector<ObjectToPrint> &objects_to_print,
|
||||||
const std::vector<std::vector<Slic3r::Polygon> > &convex_unreachable_zones,
|
const std::vector<std::vector<Slic3r::Polygon> > &convex_unreachable_zones,
|
||||||
const std::vector<std::vector<Slic3r::Polygon> > &box_unreachable_zones,
|
const std::vector<std::vector<Slic3r::Polygon> > &box_unreachable_zones,
|
||||||
std::vector<ScheduledPlate> &scheduled_plates)
|
std::vector<ScheduledPlate> &scheduled_plates,
|
||||||
|
std::function<void(int)> progress_callback)
|
||||||
{
|
{
|
||||||
#ifdef PROFILE
|
#ifdef PROFILE
|
||||||
clock_t start, finish;
|
clock_t start, finish;
|
||||||
@ -972,7 +1006,8 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration
|
|||||||
std::vector<Slic3r::Polygon> polygons;
|
std::vector<Slic3r::Polygon> polygons;
|
||||||
std::vector<std::vector<Slic3r::Polygon> > unreachable_polygons;
|
std::vector<std::vector<Slic3r::Polygon> > unreachable_polygons;
|
||||||
|
|
||||||
map<int, int> original_index_map;
|
std::map<int, int> original_index_map;
|
||||||
|
std::vector<int> previous_polygons;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
{
|
{
|
||||||
@ -1074,6 +1109,7 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration
|
|||||||
scale_down_unreachable_polygons);
|
scale_down_unreachable_polygons);
|
||||||
|
|
||||||
unreachable_polygons.push_back(scale_down_unreachable_polygons);
|
unreachable_polygons.push_back(scale_down_unreachable_polygons);
|
||||||
|
previous_polygons.push_back(objects_to_print[i].previous_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<int> remaining_polygons;
|
vector<int> remaining_polygons;
|
||||||
@ -1095,6 +1131,9 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int progress_objects_done = 0;
|
||||||
|
int progress_objects_total = objects_to_print.size();
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ScheduledPlate scheduled_plate;
|
ScheduledPlate scheduled_plate;
|
||||||
@ -1116,9 +1155,14 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration
|
|||||||
times_T,
|
times_T,
|
||||||
polygons,
|
polygons,
|
||||||
unreachable_polygons,
|
unreachable_polygons,
|
||||||
|
previous_polygons,
|
||||||
polygon_index_map,
|
polygon_index_map,
|
||||||
decided_polygons,
|
decided_polygons,
|
||||||
remaining_polygons);
|
remaining_polygons,
|
||||||
|
progress_objects_done,
|
||||||
|
progress_objects_total,
|
||||||
|
progress_callback);
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
{
|
{
|
||||||
@ -1166,6 +1210,7 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration
|
|||||||
|
|
||||||
scheduled_plate.scheduled_objects.push_back(ScheduledObject(original_index->second, X, Y));
|
scheduled_plate.scheduled_objects.push_back(ScheduledObject(original_index->second, X, Y));
|
||||||
}
|
}
|
||||||
|
progress_objects_done += decided_polygons.size();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1188,21 +1233,25 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vector<Polygon> next_polygons;
|
std::vector<Polygon> next_polygons;
|
||||||
vector<vector<Polygon> > next_unreachable_polygons;
|
std::vector<vector<Polygon> > next_unreachable_polygons;
|
||||||
|
std::vector<int> next_previous_polygons;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < remaining_polygons.size(); ++i)
|
for (unsigned int i = 0; i < remaining_polygons.size(); ++i)
|
||||||
{
|
{
|
||||||
next_polygons.push_back(polygons[remaining_polygons[i]]);
|
next_polygons.push_back(polygons[remaining_polygons[i]]);
|
||||||
next_unreachable_polygons.push_back(unreachable_polygons[remaining_polygons[i]]);
|
next_unreachable_polygons.push_back(unreachable_polygons[remaining_polygons[i]]);
|
||||||
|
next_previous_polygons.push_back(previous_polygons[remaining_polygons[i]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
polygons.clear();
|
polygons.clear();
|
||||||
unreachable_polygons.clear();
|
unreachable_polygons.clear();
|
||||||
|
previous_polygons.clear();
|
||||||
polygon_index_map.clear();
|
polygon_index_map.clear();
|
||||||
|
|
||||||
polygons = next_polygons;
|
polygons = next_polygons;
|
||||||
unreachable_polygons = next_unreachable_polygons;
|
unreachable_polygons = next_unreachable_polygons;
|
||||||
|
previous_polygons = next_previous_polygons;
|
||||||
|
|
||||||
vector<int> next_polygon_index_map;
|
vector<int> next_polygon_index_map;
|
||||||
map<int, int> next_original_index_map;
|
map<int, int> next_original_index_map;
|
||||||
|
@ -301,7 +301,7 @@ void introduce_ConsequentialTemporalOrderingAgainstFixed(z3::solver
|
|||||||
std::vector<Rational> &dec_values_T,
|
std::vector<Rational> &dec_values_T,
|
||||||
const std::vector<int> &fixed,
|
const std::vector<int> &fixed,
|
||||||
const std::vector<int> &undecided,
|
const std::vector<int> &undecided,
|
||||||
int temporal_spread,
|
int temporal_spread,
|
||||||
const std::vector<Slic3r::Polygon> &SEQ_UNUSED(polygons))
|
const std::vector<Slic3r::Polygon> &SEQ_UNUSED(polygons))
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < undecided.size() - 1; ++i)
|
for (unsigned int i = 0; i < undecided.size() - 1; ++i)
|
||||||
@ -333,6 +333,39 @@ void introduce_ConsequentialTemporalOrderingAgainstFixed(z3::solver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void introduce_ConsequentialTemporalLepoxAgainstFixed(z3::solver &Solver,
|
||||||
|
z3::context &Context,
|
||||||
|
const z3::expr_vector &dec_vars_T,
|
||||||
|
std::vector<Rational> &dec_values_T,
|
||||||
|
const std::vector<int> &fixed,
|
||||||
|
const std::vector<int> &undecided,
|
||||||
|
int temporal_spread,
|
||||||
|
const std::vector<Slic3r::Polygon> &SEQ_UNUSED(polygons),
|
||||||
|
const std::vector<int> &previous_polygons)
|
||||||
|
{
|
||||||
|
std::set<int> fixed_(fixed.begin(), fixed.end());
|
||||||
|
std::set<int> undecided_(undecided.begin(), undecided.end());
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < undecided.size(); ++i)
|
||||||
|
{
|
||||||
|
if (previous_polygons[undecided[i]] >= 0)
|
||||||
|
{
|
||||||
|
//Solver.add(dec_vars_T[previous_polygons[undecided[i]]] + temporal_spread < dec_vars_T[undecided[i]] && dec_vars_T[previous_polygons[undecided[i]]] + temporal_spread + temporal_spread / 2 > dec_vars_T[undecided[i]]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
{
|
||||||
|
printf("Origo\n");
|
||||||
|
for (unsigned int i = 0; i < fixed.size(); ++i)
|
||||||
|
{
|
||||||
|
printf("%.3f\n", dec_values_T[fixed[i]].as_double());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------*/
|
/*----------------------------------------------------------------*/
|
||||||
|
|
||||||
void introduce_LineNonIntersection(z3::solver &Solver,
|
void introduce_LineNonIntersection(z3::solver &Solver,
|
||||||
@ -6303,8 +6336,11 @@ void extract_DecisionValuesFromModel(const z3::model &Model,
|
|||||||
z3::expr_vector &dec_values_X,
|
z3::expr_vector &dec_values_X,
|
||||||
z3::expr_vector &dec_values_Y)
|
z3::expr_vector &dec_values_Y)
|
||||||
{
|
{
|
||||||
std::map<int, z3::expr*> values_X;
|
z3::expr_vector unordered_values_X(Context);
|
||||||
std::map<int, z3::expr*> values_Y;
|
z3::expr_vector unordered_values_Y(Context);
|
||||||
|
|
||||||
|
std::map<int, int> value_indices_X;
|
||||||
|
std::map<int, int> value_indices_Y;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < Model.size(); ++i)
|
for (unsigned int i = 0; i < Model.size(); ++i)
|
||||||
{
|
{
|
||||||
@ -6323,12 +6359,12 @@ void extract_DecisionValuesFromModel(const z3::model &Model,
|
|||||||
string_map::const_iterator var_item = dec_var_names_map.find(Model[i].name().str());
|
string_map::const_iterator var_item = dec_var_names_map.find(Model[i].name().str());
|
||||||
if (var_item != dec_var_names_map.end())
|
if (var_item != dec_var_names_map.end())
|
||||||
{
|
{
|
||||||
//printf("saving: %d <-- %.3f, %d, %d\n", var_item->second, value.as_double(), value.numerator().as_int64(), value.denominator().as_int64());
|
value_indices_X[var_item->second] = i;
|
||||||
values_X[var_item->second] = new z3::expr(Context.real_val(value.numerator().as_int64(), value.denominator().as_int64()));
|
unordered_values_X.push_back(z3::expr(Context.real_val(value.numerator().as_int64(), value.denominator().as_int64())));
|
||||||
//dec_values_X[var_item->second] = value;
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
{
|
{
|
||||||
printf("saved: %.3f\n", values_X[var_item->second]->as_double());
|
printf("saved: %.3f\n", unordered_values_X.back()->as_double());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -6339,15 +6375,12 @@ void extract_DecisionValuesFromModel(const z3::model &Model,
|
|||||||
string_map::const_iterator var_item = dec_var_names_map.find(Model[i].name().str());
|
string_map::const_iterator var_item = dec_var_names_map.find(Model[i].name().str());
|
||||||
if (var_item != dec_var_names_map.end())
|
if (var_item != dec_var_names_map.end())
|
||||||
{
|
{
|
||||||
//printf("saving: %d <-- %.3f\n", var_item->second, value.as_double());
|
value_indices_Y[var_item->second] = i;
|
||||||
|
unordered_values_Y.push_back(z3::expr(Context.real_val(value.numerator().as_int64(), value.denominator().as_int64())));
|
||||||
values_Y[var_item->second] = new z3::expr(Context.real_val(value.numerator().as_int64(), value.denominator().as_int64()));
|
|
||||||
//dec_values_Y[var_item->second] = value;
|
|
||||||
//printf("saved: %.3f, %.3f\n", values_X[var_item->second]->as_dou
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
{
|
{
|
||||||
printf("saved: %.3f\n", values_Y[var_item->second]->as_double());
|
printf("saved: %.3f\n", unordered_values_Y.back()->as_double());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -6363,15 +6396,13 @@ void extract_DecisionValuesFromModel(const z3::model &Model,
|
|||||||
dec_values_X.resize(0);
|
dec_values_X.resize(0);
|
||||||
dec_values_Y.resize(0);
|
dec_values_Y.resize(0);
|
||||||
|
|
||||||
for (std::map<int, z3::expr*>::const_iterator value = values_X.begin(); value != values_X.end(); ++value)
|
for (std::map<int, int>::const_iterator value = value_indices_X.begin(); value != value_indices_X.end(); ++value)
|
||||||
{
|
{
|
||||||
dec_values_X.push_back(*value->second);
|
dec_values_X.push_back(unordered_values_X[value->second]);
|
||||||
delete value->second;
|
|
||||||
}
|
}
|
||||||
for (std::map<int, z3::expr*>::const_iterator value = values_Y.begin(); value != values_Y.end(); ++value)
|
for (std::map<int, int>::const_iterator value = value_indices_Y.begin(); value != value_indices_Y.end(); ++value)
|
||||||
{
|
{
|
||||||
dec_values_Y.push_back(*value->second);
|
dec_values_Y.push_back(unordered_values_Y[value->second]);
|
||||||
delete value->second;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9712,7 +9743,7 @@ bool optimize_SubglobalSequentialPolygonNonoverlappingBinaryCentered(const Solve
|
|||||||
z3::expr_vector local_dec_vars_T(z_context);
|
z3::expr_vector local_dec_vars_T(z_context);
|
||||||
|
|
||||||
vector<Rational> local_values_X;
|
vector<Rational> local_values_X;
|
||||||
vector<Rational> local_values_Y;
|
vector<Rational> local_values_Y;
|
||||||
vector<Rational> local_values_T;
|
vector<Rational> local_values_T;
|
||||||
|
|
||||||
local_values_X.resize(polygons.size());
|
local_values_X.resize(polygons.size());
|
||||||
@ -9909,9 +9940,13 @@ bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const So
|
|||||||
std::vector<Rational> &dec_values_T,
|
std::vector<Rational> &dec_values_T,
|
||||||
const std::vector<Slic3r::Polygon> &polygons,
|
const std::vector<Slic3r::Polygon> &polygons,
|
||||||
const std::vector<Slic3r::Polygon> &unreachable_polygons,
|
const std::vector<Slic3r::Polygon> &unreachable_polygons,
|
||||||
|
const std::vector<int> &previous_polygons,
|
||||||
const std::vector<int> &undecided_polygons,
|
const std::vector<int> &undecided_polygons,
|
||||||
std::vector<int> &decided_polygons,
|
std::vector<int> &decided_polygons,
|
||||||
std::vector<int> &remaining_polygons)
|
std::vector<int> &remaining_polygons,
|
||||||
|
int objects_done,
|
||||||
|
int total_objects,
|
||||||
|
std::function<void(int)> progress_callback)
|
||||||
{
|
{
|
||||||
std::vector<std::vector<Slic3r::Polygon> > _unreachable_polygons;
|
std::vector<std::vector<Slic3r::Polygon> > _unreachable_polygons;
|
||||||
_unreachable_polygons.resize(unreachable_polygons.size());
|
_unreachable_polygons.resize(unreachable_polygons.size());
|
||||||
@ -9927,9 +9962,13 @@ bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const So
|
|||||||
dec_values_T,
|
dec_values_T,
|
||||||
polygons,
|
polygons,
|
||||||
_unreachable_polygons,
|
_unreachable_polygons,
|
||||||
|
previous_polygons,
|
||||||
undecided_polygons,
|
undecided_polygons,
|
||||||
decided_polygons,
|
decided_polygons,
|
||||||
remaining_polygons);
|
remaining_polygons,
|
||||||
|
objects_done,
|
||||||
|
total_objects,
|
||||||
|
progress_callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -9944,9 +9983,13 @@ bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const So
|
|||||||
std::vector<Rational> &dec_values_T,
|
std::vector<Rational> &dec_values_T,
|
||||||
const std::vector<Slic3r::Polygon> &polygons,
|
const std::vector<Slic3r::Polygon> &polygons,
|
||||||
const std::vector<std::vector<Slic3r::Polygon> > &unreachable_polygons,
|
const std::vector<std::vector<Slic3r::Polygon> > &unreachable_polygons,
|
||||||
|
const std::vector<int> &previous_polygons,
|
||||||
const std::vector<int> &undecided_polygons,
|
const std::vector<int> &undecided_polygons,
|
||||||
std::vector<int> &decided_polygons,
|
std::vector<int> &decided_polygons,
|
||||||
std::vector<int> &remaining_polygons)
|
std::vector<int> &remaining_polygons,
|
||||||
|
int objects_done,
|
||||||
|
int total_objects,
|
||||||
|
std::function<void(int)> progress_callback)
|
||||||
{
|
{
|
||||||
vector<int> undecided;
|
vector<int> undecided;
|
||||||
|
|
||||||
@ -10002,7 +10045,6 @@ bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const So
|
|||||||
int object_group_size = MIN((unsigned int)solver_configuration.object_group_size, polygons.size() - curr_polygon);
|
int object_group_size = MIN((unsigned int)solver_configuration.object_group_size, polygons.size() - curr_polygon);
|
||||||
|
|
||||||
undecided.clear();
|
undecided.clear();
|
||||||
|
|
||||||
int remaining_polygon = 0;
|
int remaining_polygon = 0;
|
||||||
|
|
||||||
for (int i = object_group_size - 1; i >= 0; --i)
|
for (int i = object_group_size - 1; i >= 0; --i)
|
||||||
@ -10064,7 +10106,6 @@ bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const So
|
|||||||
local_values_Y[j].denominator,
|
local_values_Y[j].denominator,
|
||||||
local_values_T[j].numerator,
|
local_values_T[j].numerator,
|
||||||
local_values_T[j].denominator);
|
local_values_T[j].denominator);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -10078,6 +10119,16 @@ bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const So
|
|||||||
solver_configuration.temporal_spread,
|
solver_configuration.temporal_spread,
|
||||||
polygons);
|
polygons);
|
||||||
|
|
||||||
|
introduce_ConsequentialTemporalLepoxAgainstFixed(z_solver,
|
||||||
|
z_context,
|
||||||
|
local_dec_vars_T,
|
||||||
|
local_values_T,
|
||||||
|
decided_polygons,
|
||||||
|
undecided,
|
||||||
|
solver_configuration.temporal_spread,
|
||||||
|
polygons,
|
||||||
|
previous_polygons);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
{
|
{
|
||||||
printf("%ld,%ld\n", local_values_X.size(), local_values_Y.size());
|
printf("%ld,%ld\n", local_values_X.size(), local_values_Y.size());
|
||||||
@ -10093,6 +10144,8 @@ bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const So
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
progress_callback((SEQ_PROGRESS_RANGE * (decided_polygons.size() + objects_done)) / total_objects);
|
||||||
|
|
||||||
optimized = optimize_ConsequentialWeakPolygonNonoverlappingBinaryCentered(z_solver,
|
optimized = optimize_ConsequentialWeakPolygonNonoverlappingBinaryCentered(z_solver,
|
||||||
z_context,
|
z_context,
|
||||||
solver_configuration,
|
solver_configuration,
|
||||||
@ -10136,8 +10189,12 @@ bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const So
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
curr_polygon += polygons.size() - curr_polygon;
|
||||||
|
progress_callback((SEQ_PROGRESS_RANGE * (decided_polygons.size() + objects_done)) / total_objects);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
progress_callback((SEQ_PROGRESS_RANGE * (decided_polygons.size() + objects_done)) / total_objects);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -10149,10 +10206,13 @@ bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const So
|
|||||||
#endif
|
#endif
|
||||||
remaining_polygons.push_back(undecided_polygons[curr_polygon + remaining_polygon++]);
|
remaining_polygons.push_back(undecided_polygons[curr_polygon + remaining_polygon++]);
|
||||||
}
|
}
|
||||||
|
|
||||||
missing.push_back(undecided.back());
|
missing.push_back(undecided.back());
|
||||||
undecided.pop_back();
|
undecided.pop_back();
|
||||||
|
|
||||||
--object_group_size;
|
--object_group_size;
|
||||||
|
|
||||||
|
progress_callback((SEQ_PROGRESS_RANGE * (decided_polygons.size() + objects_done)) / total_objects);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PROFILE
|
#ifdef PROFILE
|
||||||
|
@ -210,6 +210,7 @@ int solve_SequentialPrint(const CommandParameters &command_parameters)
|
|||||||
|
|
||||||
std::vector<Slic3r::Polygon> polygons;
|
std::vector<Slic3r::Polygon> polygons;
|
||||||
std::vector<std::vector<Slic3r::Polygon> > unreachable_polygons;
|
std::vector<std::vector<Slic3r::Polygon> > unreachable_polygons;
|
||||||
|
std::vector<int> previous_polygons;
|
||||||
|
|
||||||
printf(" Preparing objects ...\n");
|
printf(" Preparing objects ...\n");
|
||||||
|
|
||||||
@ -317,6 +318,7 @@ int solve_SequentialPrint(const CommandParameters &command_parameters)
|
|||||||
scale_down_unreachable_polygons);
|
scale_down_unreachable_polygons);
|
||||||
|
|
||||||
unreachable_polygons.push_back(scale_down_unreachable_polygons);
|
unreachable_polygons.push_back(scale_down_unreachable_polygons);
|
||||||
|
previous_polygons.push_back(objects_to_print[i].previous_id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -341,6 +343,8 @@ int solve_SequentialPrint(const CommandParameters &command_parameters)
|
|||||||
|
|
||||||
unreachable_polygons.push_back(scale_down_unreachable_polygons);
|
unreachable_polygons.push_back(scale_down_unreachable_polygons);
|
||||||
polygons.push_back(scale_down_object_polygon);
|
polygons.push_back(scale_down_object_polygon);
|
||||||
|
|
||||||
|
previous_polygons.push_back(objects_to_print[i].previous_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
SVG preview_svg("sequential_prusa.svg");
|
SVG preview_svg("sequential_prusa.svg");
|
||||||
@ -374,6 +378,9 @@ int solve_SequentialPrint(const CommandParameters &command_parameters)
|
|||||||
|
|
||||||
int plate_index = 0;
|
int plate_index = 0;
|
||||||
|
|
||||||
|
int progress_objects_done = 0;
|
||||||
|
int progress_objects_total = objects_to_print.size();
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
decided_polygons.clear();
|
decided_polygons.clear();
|
||||||
@ -390,9 +397,13 @@ int solve_SequentialPrint(const CommandParameters &command_parameters)
|
|||||||
times_T,
|
times_T,
|
||||||
polygons,
|
polygons,
|
||||||
unreachable_polygons,
|
unreachable_polygons,
|
||||||
|
previous_polygons,
|
||||||
polygon_index_map,
|
polygon_index_map,
|
||||||
decided_polygons,
|
decided_polygons,
|
||||||
remaining_polygons);
|
remaining_polygons,
|
||||||
|
progress_objects_done,
|
||||||
|
progress_objects_total);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -405,6 +416,7 @@ int solve_SequentialPrint(const CommandParameters &command_parameters)
|
|||||||
polygon_index_map,
|
polygon_index_map,
|
||||||
decided_polygons,
|
decided_polygons,
|
||||||
remaining_polygons);
|
remaining_polygons);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(" Object scheduling/arranging ... finished\n");
|
printf(" Object scheduling/arranging ... finished\n");
|
||||||
@ -432,6 +444,7 @@ int solve_SequentialPrint(const CommandParameters &command_parameters)
|
|||||||
{
|
{
|
||||||
scheduled_polygons.insert(std::pair<double, int>(times_T[decided_polygons[i]].as_double(), decided_polygons[i]));
|
scheduled_polygons.insert(std::pair<double, int>(times_T[decided_polygons[i]].as_double(), decided_polygons[i]));
|
||||||
}
|
}
|
||||||
|
progress_objects_done += decided_polygons.size();
|
||||||
|
|
||||||
string output_filename;
|
string output_filename;
|
||||||
|
|
||||||
@ -722,6 +735,7 @@ int solve_SequentialPrint(const CommandParameters &command_parameters)
|
|||||||
|
|
||||||
vector<Polygon> next_polygons;
|
vector<Polygon> next_polygons;
|
||||||
vector<vector<Polygon> > next_unreachable_polygons;
|
vector<vector<Polygon> > next_unreachable_polygons;
|
||||||
|
vector<int> next_previous_polygons;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
{
|
{
|
||||||
@ -735,14 +749,17 @@ int solve_SequentialPrint(const CommandParameters &command_parameters)
|
|||||||
{
|
{
|
||||||
next_polygons.push_back(polygons[remaining_polygons[i]]);
|
next_polygons.push_back(polygons[remaining_polygons[i]]);
|
||||||
next_unreachable_polygons.push_back(unreachable_polygons[remaining_polygons[i]]);
|
next_unreachable_polygons.push_back(unreachable_polygons[remaining_polygons[i]]);
|
||||||
|
next_previous_polygons.push_back(previous_polygons[remaining_polygons[i]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
polygons.clear();
|
polygons.clear();
|
||||||
unreachable_polygons.clear();
|
unreachable_polygons.clear();
|
||||||
|
previous_polygons.clear();
|
||||||
polygon_index_map.clear();
|
polygon_index_map.clear();
|
||||||
|
|
||||||
polygons = next_polygons;
|
polygons = next_polygons;
|
||||||
unreachable_polygons = next_unreachable_polygons;
|
unreachable_polygons = next_unreachable_polygons;
|
||||||
|
previous_polygons = next_previous_polygons;
|
||||||
|
|
||||||
vector<int> next_polygon_index_map;
|
vector<int> next_polygon_index_map;
|
||||||
//vector<int> next_original_index_map;
|
//vector<int> next_original_index_map;
|
||||||
|
@ -359,7 +359,8 @@ int test_interface_5(void)
|
|||||||
|
|
||||||
scheduled_plates = schedule_ObjectsForSequentialPrint(solver_configuration,
|
scheduled_plates = schedule_ObjectsForSequentialPrint(solver_configuration,
|
||||||
printer_geometry,
|
printer_geometry,
|
||||||
objects_to_print);
|
objects_to_print,
|
||||||
|
[](int progress) { printf("Progress: %d\n", progress); });
|
||||||
|
|
||||||
printf("Object scheduling for sequential print SUCCESSFUL !\n");
|
printf("Object scheduling for sequential print SUCCESSFUL !\n");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user