mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-24 22:04:31 +08:00
Updating interface for object instances via object gluing.
This commit is contained in:
parent
73cd351e2d
commit
967a0710d3
@ -89,8 +89,7 @@ struct SolverConfiguration
|
||||
struct ObjectToPrint
|
||||
{
|
||||
int id = 0;
|
||||
bool lepox = false; /* object must be scheduled right after the previous object */
|
||||
int previous_id = -1; /* object 'id' will be scheduled right after object 'previous_id' */
|
||||
bool glued_to_next = false; /* the next object must be scheduled right after this object */
|
||||
coord_t total_height = 0;
|
||||
std::vector<std::pair<coord_t, Slic3r::Polygon>> pgns_at_height;
|
||||
};
|
||||
|
@ -318,7 +318,7 @@ void schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver
|
||||
std::vector<std::vector<Slic3r::Polygon> > unreachable_polygons;
|
||||
|
||||
std::map<int, int> original_index_map;
|
||||
std::vector<int> previous_polygons;
|
||||
std::vector<bool> lepox_to_next;
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
@ -360,21 +360,21 @@ void schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver
|
||||
unreachable_polygons.push_back(scale_down_unreachable_polygons);
|
||||
polygons.push_back(scale_down_object_polygon);
|
||||
|
||||
previous_polygons.push_back(objects_to_print[i].previous_id);
|
||||
lepox_to_next.push_back(objects_to_print[i].glued_to_next);
|
||||
}
|
||||
|
||||
vector<int> remaining_polygons;
|
||||
vector<int> polygon_index_map;
|
||||
vector<int> decided_polygons;
|
||||
std::vector<int> remaining_polygons;
|
||||
std::vector<int> polygon_index_map;
|
||||
std::vector<int> decided_polygons;
|
||||
|
||||
for (unsigned int index = 0; index < polygons.size(); ++index)
|
||||
{
|
||||
polygon_index_map.push_back(index);
|
||||
}
|
||||
|
||||
vector<Rational> poly_positions_X;
|
||||
vector<Rational> poly_positions_Y;
|
||||
vector<Rational> times_T;
|
||||
std::vector<Rational> poly_positions_X;
|
||||
std::vector<Rational> poly_positions_Y;
|
||||
std::vector<Rational> times_T;
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
@ -406,7 +406,7 @@ void schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver
|
||||
times_T,
|
||||
polygons,
|
||||
unreachable_polygons,
|
||||
previous_polygons,
|
||||
lepox_to_next,
|
||||
polygon_index_map,
|
||||
decided_polygons,
|
||||
remaining_polygons,
|
||||
@ -484,28 +484,30 @@ void schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver
|
||||
}
|
||||
#endif
|
||||
|
||||
vector<Polygon> next_polygons;
|
||||
vector<vector<Polygon> > next_unreachable_polygons;
|
||||
vector<int> next_previous_polygons;
|
||||
std::vector<Polygon> next_polygons;
|
||||
std::vector<vector<Polygon> > next_unreachable_polygons;
|
||||
std::vector<bool> next_lepox_to_next;
|
||||
|
||||
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]]);
|
||||
next_lepox_to_next.push_back(lepox_to_next[remaining_polygons[i]]);
|
||||
}
|
||||
|
||||
|
||||
/* TODO: remove */
|
||||
polygons.clear();
|
||||
unreachable_polygons.clear();
|
||||
previous_polygons.clear();
|
||||
lepox_to_next.clear();
|
||||
|
||||
polygon_index_map.clear();
|
||||
|
||||
polygons = next_polygons;
|
||||
unreachable_polygons = next_unreachable_polygons;
|
||||
previous_polygons = next_previous_polygons;
|
||||
lepox_to_next = next_lepox_to_next;
|
||||
|
||||
vector<int> next_polygon_index_map;
|
||||
map<int, int> next_original_index_map;
|
||||
std::vector<int> next_polygon_index_map;
|
||||
std::map<int, int> next_original_index_map;
|
||||
|
||||
for (unsigned int index = 0; index < polygons.size(); ++index)
|
||||
{
|
||||
@ -561,9 +563,9 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_
|
||||
|
||||
std::vector<Slic3r::Polygon> polygons;
|
||||
std::vector<std::vector<Slic3r::Polygon> > unreachable_polygons;
|
||||
std::vector<int> previous_polygons;
|
||||
std::vector<bool> lepox_to_next;
|
||||
|
||||
map<int, int> original_index_map;
|
||||
std::map<int, int> original_index_map;
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
@ -770,7 +772,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);
|
||||
lepox_to_next.push_back(objects_to_print[i].glued_to_next);
|
||||
}
|
||||
|
||||
vector<int> remaining_polygons;
|
||||
@ -816,7 +818,7 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_
|
||||
times_T,
|
||||
polygons,
|
||||
unreachable_polygons,
|
||||
previous_polygons,
|
||||
lepox_to_next,
|
||||
polygon_index_map,
|
||||
decided_polygons,
|
||||
remaining_polygons,
|
||||
@ -893,28 +895,30 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_
|
||||
}
|
||||
#endif
|
||||
|
||||
vector<Polygon> next_polygons;
|
||||
vector<vector<Polygon> > next_unreachable_polygons;
|
||||
vector<int> next_previous_polygons;
|
||||
std::vector<Polygon> next_polygons;
|
||||
std::vector<vector<Polygon> > next_unreachable_polygons;
|
||||
std::vector<bool> next_lepox_to_next;
|
||||
|
||||
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]]);
|
||||
next_lepox_to_next.push_back(lepox_to_next[remaining_polygons[i]]);
|
||||
}
|
||||
|
||||
|
||||
/* TODO: remove */
|
||||
polygons.clear();
|
||||
unreachable_polygons.clear();
|
||||
previous_polygons.clear();
|
||||
lepox_to_next.clear();
|
||||
|
||||
polygon_index_map.clear();
|
||||
|
||||
polygons = next_polygons;
|
||||
unreachable_polygons = next_unreachable_polygons;
|
||||
previous_polygons = next_previous_polygons;
|
||||
lepox_to_next = next_lepox_to_next;
|
||||
|
||||
vector<int> next_polygon_index_map;
|
||||
map<int, int> next_original_index_map;
|
||||
std::vector<int> next_polygon_index_map;
|
||||
std::map<int, int> next_original_index_map;
|
||||
|
||||
for (unsigned int index = 0; index < polygons.size(); ++index)
|
||||
{
|
||||
@ -1007,7 +1011,7 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration
|
||||
std::vector<std::vector<Slic3r::Polygon> > unreachable_polygons;
|
||||
|
||||
std::map<int, int> original_index_map;
|
||||
std::vector<int> previous_polygons;
|
||||
std::vector<bool> lepox_to_next;
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
@ -1109,21 +1113,21 @@ 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);
|
||||
lepox_to_next.push_back(objects_to_print[i].glued_to_next);
|
||||
}
|
||||
|
||||
vector<int> remaining_polygons;
|
||||
vector<int> polygon_index_map;
|
||||
vector<int> decided_polygons;
|
||||
std::vector<int> remaining_polygons;
|
||||
std::vector<int> polygon_index_map;
|
||||
std::vector<int> decided_polygons;
|
||||
|
||||
for (unsigned int index = 0; index < polygons.size(); ++index)
|
||||
{
|
||||
polygon_index_map.push_back(index);
|
||||
}
|
||||
|
||||
vector<Rational> poly_positions_X;
|
||||
vector<Rational> poly_positions_Y;
|
||||
vector<Rational> times_T;
|
||||
std::vector<Rational> poly_positions_X;
|
||||
std::vector<Rational> poly_positions_Y;
|
||||
std::vector<Rational> times_T;
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
@ -1155,7 +1159,7 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration
|
||||
times_T,
|
||||
polygons,
|
||||
unreachable_polygons,
|
||||
previous_polygons,
|
||||
lepox_to_next,
|
||||
polygon_index_map,
|
||||
decided_polygons,
|
||||
remaining_polygons,
|
||||
@ -1235,26 +1239,28 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration
|
||||
|
||||
std::vector<Polygon> next_polygons;
|
||||
std::vector<vector<Polygon> > next_unreachable_polygons;
|
||||
std::vector<int> next_previous_polygons;
|
||||
std::vector<bool> next_lepox_to_next;
|
||||
|
||||
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]]);
|
||||
next_lepox_to_next.push_back(lepox_to_next[remaining_polygons[i]]);
|
||||
}
|
||||
|
||||
|
||||
/* TODO: remove */
|
||||
polygons.clear();
|
||||
unreachable_polygons.clear();
|
||||
previous_polygons.clear();
|
||||
lepox_to_next.clear();
|
||||
|
||||
polygon_index_map.clear();
|
||||
|
||||
polygons = next_polygons;
|
||||
unreachable_polygons = next_unreachable_polygons;
|
||||
previous_polygons = next_previous_polygons;
|
||||
lepox_to_next = next_lepox_to_next;
|
||||
|
||||
vector<int> next_polygon_index_map;
|
||||
map<int, int> next_original_index_map;
|
||||
std::vector<int> next_polygon_index_map;
|
||||
std::map<int, int> next_original_index_map;
|
||||
|
||||
for (unsigned int index = 0; index < polygons.size(); ++index)
|
||||
{
|
||||
|
@ -341,15 +341,16 @@ void introduce_ConsequentialTemporalLepoxAgainstFixed(z3::solver
|
||||
const std::vector<int> &undecided,
|
||||
int temporal_spread,
|
||||
const std::vector<Slic3r::Polygon> &SEQ_UNUSED(polygons),
|
||||
const std::vector<int> &previous_polygons)
|
||||
const std::vector<bool> &lepox_to_next)
|
||||
{
|
||||
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)
|
||||
if (lepox_to_next[undecided[i]])
|
||||
{
|
||||
/* TODO: we know what to do */
|
||||
//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]]);
|
||||
}
|
||||
}
|
||||
@ -9939,7 +9940,7 @@ 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<bool> &lepox_to_next,
|
||||
const std::vector<int> &undecided_polygons,
|
||||
std::vector<int> &decided_polygons,
|
||||
std::vector<int> &remaining_polygons,
|
||||
@ -9961,7 +9962,7 @@ bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const So
|
||||
dec_values_T,
|
||||
polygons,
|
||||
_unreachable_polygons,
|
||||
previous_polygons,
|
||||
lepox_to_next,
|
||||
undecided_polygons,
|
||||
decided_polygons,
|
||||
remaining_polygons,
|
||||
@ -9982,7 +9983,7 @@ 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<bool> &lepox_to_next,
|
||||
const std::vector<int> &undecided_polygons,
|
||||
std::vector<int> &decided_polygons,
|
||||
std::vector<int> &remaining_polygons,
|
||||
@ -10123,7 +10124,7 @@ bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const So
|
||||
undecided,
|
||||
solver_configuration.temporal_spread,
|
||||
polygons,
|
||||
previous_polygons);
|
||||
lepox_to_next);
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
@ -10174,7 +10175,7 @@ bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const So
|
||||
{
|
||||
dec_values_X[undecided[i]] = local_values_X[undecided[i]];
|
||||
dec_values_Y[undecided[i]] = local_values_Y[undecided[i]];
|
||||
dec_values_T[undecided[i]] = local_values_T[undecided[i]];
|
||||
dec_values_T[undecided[i]] = local_values_T[undecided[i]];
|
||||
decided_polygons.push_back(undecided[i]);
|
||||
}
|
||||
augment_TemporalSpread(solver_configuration, dec_values_T, decided_polygons);
|
||||
@ -10207,7 +10208,6 @@ bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const So
|
||||
undecided.pop_back();
|
||||
|
||||
--object_group_size;
|
||||
|
||||
progress_callback((SEQ_PROGRESS_RANGE * (decided_polygons.size() + objects_done)) / total_objects);
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ const double SEQ_DECIMATION_TOLERANCE = 400000.0;
|
||||
|
||||
const double SEQ_DECIMATION_TOLERANCE_VALUE_UNDEFINED = 0.0;
|
||||
const double SEQ_DECIMATION_TOLERANCE_VALUE_LOW = 150000.0;
|
||||
const double SEQ_DECIMATION_TOLERANCE_VALUE_HIGH = 450000.0;
|
||||
const double SEQ_DECIMATION_TOLERANCE_VALUE_HIGH = 650000.0;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------*/
|
||||
@ -300,6 +300,16 @@ void introduce_ConsequentialTemporalOrderingAgainstFixed(z3::solver
|
||||
int temporal_spread,
|
||||
const std::vector<Slic3r::Polygon> &polygons);
|
||||
|
||||
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<bool> &lepox_to_next);
|
||||
|
||||
/*----------------------------------------------------------------*/
|
||||
|
||||
void introduce_LineNonIntersection(z3::solver &Solver,
|
||||
@ -1537,13 +1547,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<bool> &lepox_to_next,
|
||||
const std::vector<int> &undecided_polygons,
|
||||
std::vector<int> &decided_polygons,
|
||||
std::vector<int> &remaining_polygons,
|
||||
int objects_done,
|
||||
int total_objects,
|
||||
std::function<void(int)> progress_callback = [](int progress){});
|
||||
int total_objects,
|
||||
std::function<void(int)> progress_callback = [](int progress){});
|
||||
|
||||
bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const SolverConfiguration &solver_configuration,
|
||||
std::vector<Rational> &dec_values_X,
|
||||
@ -1551,12 +1561,12 @@ 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<bool> &lepox_to_next,
|
||||
const std::vector<int> &undecided_polygons,
|
||||
std::vector<int> &decided_polygons,
|
||||
std::vector<int> &remaining_polygons,
|
||||
int objects_done,
|
||||
int total_objects,
|
||||
int total_objects,
|
||||
std::function<void(int)> progress_callback = [](int progress){});
|
||||
|
||||
/*----------------------------------------------------------------*/
|
||||
|
@ -210,7 +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;
|
||||
std::vector<bool> lepox_to_next;
|
||||
|
||||
printf(" Preparing objects ...\n");
|
||||
|
||||
@ -318,7 +318,7 @@ int solve_SequentialPrint(const CommandParameters &command_parameters)
|
||||
scale_down_unreachable_polygons);
|
||||
|
||||
unreachable_polygons.push_back(scale_down_unreachable_polygons);
|
||||
previous_polygons.push_back(objects_to_print[i].previous_id);
|
||||
lepox_to_next.push_back(objects_to_print[i].glued_to_next);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -344,7 +344,7 @@ int solve_SequentialPrint(const CommandParameters &command_parameters)
|
||||
unreachable_polygons.push_back(scale_down_unreachable_polygons);
|
||||
polygons.push_back(scale_down_object_polygon);
|
||||
|
||||
previous_polygons.push_back(objects_to_print[i].previous_id);
|
||||
lepox_to_next.push_back(objects_to_print[i].glued_to_next);
|
||||
}
|
||||
|
||||
SVG preview_svg("sequential_prusa.svg");
|
||||
@ -397,7 +397,7 @@ int solve_SequentialPrint(const CommandParameters &command_parameters)
|
||||
times_T,
|
||||
polygons,
|
||||
unreachable_polygons,
|
||||
previous_polygons,
|
||||
lepox_to_next,
|
||||
polygon_index_map,
|
||||
decided_polygons,
|
||||
remaining_polygons,
|
||||
@ -733,9 +733,9 @@ int solve_SequentialPrint(const CommandParameters &command_parameters)
|
||||
printf("All objects fit onto plate.\n");
|
||||
}
|
||||
|
||||
vector<Polygon> next_polygons;
|
||||
vector<vector<Polygon> > next_unreachable_polygons;
|
||||
vector<int> next_previous_polygons;
|
||||
std::vector<Polygon> next_polygons;
|
||||
std::vector<vector<Polygon> > next_unreachable_polygons;
|
||||
std::vector<bool> next_lepox_to_next;
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
@ -749,21 +749,22 @@ 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]]);
|
||||
next_lepox_to_next.push_back(lepox_to_next[remaining_polygons[i]]);
|
||||
}
|
||||
|
||||
|
||||
/* TODO: remove */
|
||||
polygons.clear();
|
||||
unreachable_polygons.clear();
|
||||
previous_polygons.clear();
|
||||
lepox_to_next.clear();
|
||||
|
||||
polygon_index_map.clear();
|
||||
|
||||
polygons = next_polygons;
|
||||
unreachable_polygons = next_unreachable_polygons;
|
||||
previous_polygons = next_previous_polygons;
|
||||
lepox_to_next = next_lepox_to_next;
|
||||
|
||||
vector<int> next_polygon_index_map;
|
||||
//vector<int> next_original_index_map;
|
||||
map<int, int> next_original_index_map;
|
||||
std::vector<int> next_polygon_index_map;
|
||||
std::map<int, int> next_original_index_map;
|
||||
|
||||
for (unsigned int index = 0; index < polygons.size(); ++index)
|
||||
{
|
||||
|
@ -334,7 +334,7 @@ int test_interface_5(void)
|
||||
start = clock();
|
||||
|
||||
SolverConfiguration solver_configuration;
|
||||
solver_configuration.decimation_precision = SEQ_DECIMATION_PRECISION_HIGH;
|
||||
solver_configuration.decimation_precision = SEQ_DECIMATION_PRECISION_LOW;
|
||||
solver_configuration.object_group_size = 4;
|
||||
|
||||
printf("Loading objects ...\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user