mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-13 18:35:52 +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
|
||||
{
|
||||
int id = 0;
|
||||
int previous_id = -1; /* object 'id' will be scheduled right after object 'previous_id' */
|
||||
coord_t total_height = 0;
|
||||
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,
|
||||
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,
|
||||
const PrinterGeometry &printer_geometry,
|
||||
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,
|
||||
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,
|
||||
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<std::vector<Slic3r::Polygon> > &convex_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<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)
|
||||
{
|
||||
@ -203,7 +203,7 @@ bool check_ScheduledObjectsForSequentialPrintability(const SolverConfiguration
|
||||
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);
|
||||
}
|
||||
|
||||
for (const auto& scheduled_plate: scheduled_plates)
|
||||
@ -283,14 +283,16 @@ bool check_ScheduledObjectsForSequentialPrintability(const SolverConfiguration
|
||||
|
||||
std::vector<ScheduledPlate> schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_configuration,
|
||||
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;
|
||||
|
||||
schedule_ObjectsForSequentialPrint(solver_configuration,
|
||||
printer_geometry,
|
||||
objects_to_print,
|
||||
scheduled_plates);
|
||||
scheduled_plates,
|
||||
progress_callback);
|
||||
return scheduled_plates;
|
||||
}
|
||||
|
||||
@ -298,7 +300,8 @@ std::vector<ScheduledPlate> schedule_ObjectsForSequentialPrint(const SolverConfi
|
||||
void schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_configuration,
|
||||
const PrinterGeometry &printer_geometry,
|
||||
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
|
||||
clock_t start, finish;
|
||||
@ -314,7 +317,8 @@ void schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver
|
||||
std::vector<Slic3r::Polygon> 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
|
||||
{
|
||||
@ -354,7 +358,9 @@ void schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver
|
||||
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;
|
||||
@ -376,6 +382,9 @@ void schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver
|
||||
}
|
||||
#endif
|
||||
|
||||
int progress_objects_done = 0;
|
||||
int progress_objects_total = objects_to_print.size();
|
||||
|
||||
do
|
||||
{
|
||||
ScheduledPlate scheduled_plate;
|
||||
@ -397,9 +406,13 @@ void schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver
|
||||
times_T,
|
||||
polygons,
|
||||
unreachable_polygons,
|
||||
previous_polygons,
|
||||
polygon_index_map,
|
||||
decided_polygons,
|
||||
remaining_polygons);
|
||||
remaining_polygons,
|
||||
progress_objects_done,
|
||||
progress_objects_total,
|
||||
progress_callback);
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
@ -446,7 +459,8 @@ void schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver
|
||||
const auto& original_index = original_index_map.find(scheduled_polygon.second);
|
||||
|
||||
scheduled_plate.scheduled_objects.push_back(ScheduledObject(original_index->second, X, Y));
|
||||
}
|
||||
}
|
||||
progress_objects_done += decided_polygons.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -472,19 +486,23 @@ void schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver
|
||||
|
||||
vector<Polygon> next_polygons;
|
||||
vector<vector<Polygon> > next_unreachable_polygons;
|
||||
vector<int> next_previous_polygons;
|
||||
|
||||
for (unsigned int i = 0; i < remaining_polygons.size(); ++i)
|
||||
{
|
||||
next_polygons.push_back(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();
|
||||
unreachable_polygons.clear();
|
||||
previous_polygons.clear();
|
||||
polygon_index_map.clear();
|
||||
|
||||
polygons = next_polygons;
|
||||
unreachable_polygons = next_unreachable_polygons;
|
||||
previous_polygons = next_previous_polygons;
|
||||
|
||||
vector<int> next_polygon_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,
|
||||
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
|
||||
clock_t start, finish;
|
||||
@ -542,6 +561,7 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_
|
||||
|
||||
std::vector<Slic3r::Polygon> polygons;
|
||||
std::vector<std::vector<Slic3r::Polygon> > unreachable_polygons;
|
||||
std::vector<int> previous_polygons;
|
||||
|
||||
map<int, int> original_index_map;
|
||||
|
||||
@ -750,6 +770,7 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_
|
||||
}
|
||||
|
||||
unreachable_polygons.push_back(scale_down_unreachable_polygons);
|
||||
previous_polygons.push_back(objects_to_print[i].previous_id);
|
||||
}
|
||||
|
||||
vector<int> remaining_polygons;
|
||||
@ -771,6 +792,9 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_
|
||||
}
|
||||
#endif
|
||||
|
||||
int progress_objects_done = 0;
|
||||
int progress_objects_total = objects_to_print.size();
|
||||
|
||||
do
|
||||
{
|
||||
ScheduledPlate scheduled_plate;
|
||||
@ -792,9 +816,13 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_
|
||||
times_T,
|
||||
polygons,
|
||||
unreachable_polygons,
|
||||
previous_polygons,
|
||||
polygon_index_map,
|
||||
decided_polygons,
|
||||
remaining_polygons);
|
||||
remaining_polygons,
|
||||
progress_objects_done,
|
||||
progress_objects_total,
|
||||
progress_callback);
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
@ -841,7 +869,8 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_
|
||||
const auto& original_index = original_index_map.find(scheduled_polygon.second);
|
||||
|
||||
scheduled_plate.scheduled_objects.push_back(ScheduledObject(original_index->second, X, Y));
|
||||
}
|
||||
}
|
||||
progress_objects_done += decided_polygons.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -866,19 +895,23 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_
|
||||
|
||||
vector<Polygon> next_polygons;
|
||||
vector<vector<Polygon> > next_unreachable_polygons;
|
||||
vector<int> next_previous_polygons;
|
||||
|
||||
for (unsigned int i = 0; i < remaining_polygons.size(); ++i)
|
||||
{
|
||||
next_polygons.push_back(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();
|
||||
unreachable_polygons.clear();
|
||||
previous_polygons.clear();
|
||||
polygon_index_map.clear();
|
||||
|
||||
polygons = next_polygons;
|
||||
unreachable_polygons = next_unreachable_polygons;
|
||||
previous_polygons = next_previous_polygons;
|
||||
|
||||
vector<int> next_polygon_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<std::vector<Slic3r::Polygon> > &convex_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
|
||||
clock_t start, finish;
|
||||
@ -972,7 +1006,8 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration
|
||||
std::vector<Slic3r::Polygon> 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
|
||||
{
|
||||
@ -1074,6 +1109,7 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration
|
||||
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;
|
||||
@ -1095,6 +1131,9 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration
|
||||
}
|
||||
#endif
|
||||
|
||||
int progress_objects_done = 0;
|
||||
int progress_objects_total = objects_to_print.size();
|
||||
|
||||
do
|
||||
{
|
||||
ScheduledPlate scheduled_plate;
|
||||
@ -1116,9 +1155,14 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration
|
||||
times_T,
|
||||
polygons,
|
||||
unreachable_polygons,
|
||||
previous_polygons,
|
||||
polygon_index_map,
|
||||
decided_polygons,
|
||||
remaining_polygons);
|
||||
remaining_polygons,
|
||||
progress_objects_done,
|
||||
progress_objects_total,
|
||||
progress_callback);
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
@ -1165,7 +1209,8 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration
|
||||
const auto& original_index = original_index_map.find(scheduled_polygon.second);
|
||||
|
||||
scheduled_plate.scheduled_objects.push_back(ScheduledObject(original_index->second, X, Y));
|
||||
}
|
||||
}
|
||||
progress_objects_done += decided_polygons.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1188,21 +1233,25 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration
|
||||
}
|
||||
#endif
|
||||
|
||||
vector<Polygon> next_polygons;
|
||||
vector<vector<Polygon> > next_unreachable_polygons;
|
||||
std::vector<Polygon> next_polygons;
|
||||
std::vector<vector<Polygon> > next_unreachable_polygons;
|
||||
std::vector<int> next_previous_polygons;
|
||||
|
||||
for (unsigned int i = 0; i < remaining_polygons.size(); ++i)
|
||||
{
|
||||
next_polygons.push_back(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();
|
||||
unreachable_polygons.clear();
|
||||
previous_polygons.clear();
|
||||
polygon_index_map.clear();
|
||||
|
||||
polygons = next_polygons;
|
||||
unreachable_polygons = next_unreachable_polygons;
|
||||
previous_polygons = next_previous_polygons;
|
||||
|
||||
vector<int> next_polygon_index_map;
|
||||
map<int, int> next_original_index_map;
|
||||
|
@ -301,7 +301,7 @@ void introduce_ConsequentialTemporalOrderingAgainstFixed(z3::solver
|
||||
std::vector<Rational> &dec_values_T,
|
||||
const std::vector<int> &fixed,
|
||||
const std::vector<int> &undecided,
|
||||
int temporal_spread,
|
||||
int temporal_spread,
|
||||
const std::vector<Slic3r::Polygon> &SEQ_UNUSED(polygons))
|
||||
{
|
||||
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,
|
||||
@ -6303,8 +6336,11 @@ void extract_DecisionValuesFromModel(const z3::model &Model,
|
||||
z3::expr_vector &dec_values_X,
|
||||
z3::expr_vector &dec_values_Y)
|
||||
{
|
||||
std::map<int, z3::expr*> values_X;
|
||||
std::map<int, z3::expr*> values_Y;
|
||||
z3::expr_vector unordered_values_X(Context);
|
||||
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)
|
||||
{
|
||||
@ -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());
|
||||
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());
|
||||
values_X[var_item->second] = new z3::expr(Context.real_val(value.numerator().as_int64(), value.denominator().as_int64()));
|
||||
//dec_values_X[var_item->second] = value;
|
||||
value_indices_X[var_item->second] = i;
|
||||
unordered_values_X.push_back(z3::expr(Context.real_val(value.numerator().as_int64(), value.denominator().as_int64())));
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("saved: %.3f\n", values_X[var_item->second]->as_double());
|
||||
printf("saved: %.3f\n", unordered_values_X.back()->as_double());
|
||||
}
|
||||
#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());
|
||||
if (var_item != dec_var_names_map.end())
|
||||
{
|
||||
//printf("saving: %d <-- %.3f\n", var_item->second, value.as_double());
|
||||
|
||||
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
|
||||
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())));
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("saved: %.3f\n", values_Y[var_item->second]->as_double());
|
||||
printf("saved: %.3f\n", unordered_values_Y.back()->as_double());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -6363,15 +6396,13 @@ void extract_DecisionValuesFromModel(const z3::model &Model,
|
||||
dec_values_X.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);
|
||||
delete value->second;
|
||||
dec_values_X.push_back(unordered_values_X[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);
|
||||
delete value->second;
|
||||
dec_values_Y.push_back(unordered_values_Y[value->second]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -9712,7 +9743,7 @@ bool optimize_SubglobalSequentialPolygonNonoverlappingBinaryCentered(const Solve
|
||||
z3::expr_vector local_dec_vars_T(z_context);
|
||||
|
||||
vector<Rational> local_values_X;
|
||||
vector<Rational> local_values_Y;
|
||||
vector<Rational> local_values_Y;
|
||||
vector<Rational> local_values_T;
|
||||
|
||||
local_values_X.resize(polygons.size());
|
||||
@ -9909,9 +9940,13 @@ bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const So
|
||||
std::vector<Rational> &dec_values_T,
|
||||
const std::vector<Slic3r::Polygon> &polygons,
|
||||
const std::vector<Slic3r::Polygon> &unreachable_polygons,
|
||||
const std::vector<int> &previous_polygons,
|
||||
const std::vector<int> &undecided_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;
|
||||
_unreachable_polygons.resize(unreachable_polygons.size());
|
||||
@ -9927,9 +9962,13 @@ bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const So
|
||||
dec_values_T,
|
||||
polygons,
|
||||
_unreachable_polygons,
|
||||
previous_polygons,
|
||||
undecided_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,
|
||||
const std::vector<Slic3r::Polygon> &polygons,
|
||||
const std::vector<std::vector<Slic3r::Polygon> > &unreachable_polygons,
|
||||
const std::vector<int> &previous_polygons,
|
||||
const std::vector<int> &undecided_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;
|
||||
|
||||
@ -9958,7 +10001,7 @@ bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const So
|
||||
dec_values_T.resize(polygons.size());
|
||||
|
||||
int box_half_x_max = solver_configuration.x_plate_bounding_box_size / 2;
|
||||
int box_half_y_max = solver_configuration.y_plate_bounding_box_size / 2;
|
||||
int box_half_y_max = solver_configuration.y_plate_bounding_box_size / 2;
|
||||
|
||||
for (unsigned int curr_polygon = 0; curr_polygon < polygons.size(); /* nothing */)
|
||||
{
|
||||
@ -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);
|
||||
|
||||
undecided.clear();
|
||||
|
||||
int remaining_polygon = 0;
|
||||
|
||||
for (int i = object_group_size - 1; i >= 0; --i)
|
||||
@ -10063,8 +10105,7 @@ bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const So
|
||||
local_values_Y[j].numerator,
|
||||
local_values_Y[j].denominator,
|
||||
local_values_T[j].numerator,
|
||||
local_values_T[j].denominator);
|
||||
|
||||
local_values_T[j].denominator);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -10078,6 +10119,16 @@ bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const So
|
||||
solver_configuration.temporal_spread,
|
||||
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
|
||||
{
|
||||
printf("%ld,%ld\n", local_values_X.size(), local_values_Y.size());
|
||||
@ -10093,6 +10144,8 @@ bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const So
|
||||
}
|
||||
#endif
|
||||
|
||||
progress_callback((SEQ_PROGRESS_RANGE * (decided_polygons.size() + objects_done)) / total_objects);
|
||||
|
||||
optimized = optimize_ConsequentialWeakPolygonNonoverlappingBinaryCentered(z_solver,
|
||||
z_context,
|
||||
solver_configuration,
|
||||
@ -10136,8 +10189,12 @@ bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const So
|
||||
}
|
||||
else
|
||||
{
|
||||
curr_polygon += polygons.size() - curr_polygon;
|
||||
progress_callback((SEQ_PROGRESS_RANGE * (decided_polygons.size() + objects_done)) / total_objects);
|
||||
return true;
|
||||
}
|
||||
|
||||
progress_callback((SEQ_PROGRESS_RANGE * (decided_polygons.size() + objects_done)) / total_objects);
|
||||
break;
|
||||
}
|
||||
else
|
||||
@ -10148,11 +10205,14 @@ bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const So
|
||||
}
|
||||
#endif
|
||||
remaining_polygons.push_back(undecided_polygons[curr_polygon + remaining_polygon++]);
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -210,6 +210,7 @@ int solve_SequentialPrint(const CommandParameters &command_parameters)
|
||||
|
||||
std::vector<Slic3r::Polygon> polygons;
|
||||
std::vector<std::vector<Slic3r::Polygon> > unreachable_polygons;
|
||||
std::vector<int> previous_polygons;
|
||||
|
||||
printf(" Preparing objects ...\n");
|
||||
|
||||
@ -316,7 +317,8 @@ int solve_SequentialPrint(const CommandParameters &command_parameters)
|
||||
SEQ_UNREACHABLE_POLYGON_BOX_LEVELS_MK4,
|
||||
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
|
||||
{
|
||||
@ -340,7 +342,9 @@ int solve_SequentialPrint(const CommandParameters &command_parameters)
|
||||
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");
|
||||
@ -373,6 +377,9 @@ int solve_SequentialPrint(const CommandParameters &command_parameters)
|
||||
printf(" Preparing objects ... finished\n");
|
||||
|
||||
int plate_index = 0;
|
||||
|
||||
int progress_objects_done = 0;
|
||||
int progress_objects_total = objects_to_print.size();
|
||||
|
||||
do
|
||||
{
|
||||
@ -390,9 +397,13 @@ int solve_SequentialPrint(const CommandParameters &command_parameters)
|
||||
times_T,
|
||||
polygons,
|
||||
unreachable_polygons,
|
||||
previous_polygons,
|
||||
polygon_index_map,
|
||||
decided_polygons,
|
||||
remaining_polygons);
|
||||
remaining_polygons,
|
||||
progress_objects_done,
|
||||
progress_objects_total);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -404,7 +415,8 @@ int solve_SequentialPrint(const CommandParameters &command_parameters)
|
||||
unreachable_polygons,
|
||||
polygon_index_map,
|
||||
decided_polygons,
|
||||
remaining_polygons);
|
||||
remaining_polygons);
|
||||
|
||||
}
|
||||
|
||||
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]));
|
||||
}
|
||||
progress_objects_done += decided_polygons.size();
|
||||
|
||||
string output_filename;
|
||||
|
||||
@ -722,6 +735,7 @@ int solve_SequentialPrint(const CommandParameters &command_parameters)
|
||||
|
||||
vector<Polygon> next_polygons;
|
||||
vector<vector<Polygon> > next_unreachable_polygons;
|
||||
vector<int> next_previous_polygons;
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
@ -735,14 +749,17 @@ int solve_SequentialPrint(const CommandParameters &command_parameters)
|
||||
{
|
||||
next_polygons.push_back(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();
|
||||
unreachable_polygons.clear();
|
||||
previous_polygons.clear();
|
||||
polygon_index_map.clear();
|
||||
|
||||
polygons = next_polygons;
|
||||
unreachable_polygons = next_unreachable_polygons;
|
||||
previous_polygons = next_previous_polygons;
|
||||
|
||||
vector<int> next_polygon_index_map;
|
||||
//vector<int> next_original_index_map;
|
||||
|
@ -359,7 +359,8 @@ int test_interface_5(void)
|
||||
|
||||
scheduled_plates = schedule_ObjectsForSequentialPrint(solver_configuration,
|
||||
printer_geometry,
|
||||
objects_to_print);
|
||||
objects_to_print,
|
||||
[](int progress) { printf("Progress: %d\n", progress); });
|
||||
|
||||
printf("Object scheduling for sequential print SUCCESSFUL !\n");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user