mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-12 20:39:00 +08:00
Added interface function for determining a pair of objects in sequential collision.
This commit is contained in:
parent
33ff12af71
commit
cfcfeb8cab
@ -137,6 +137,21 @@ bool check_ScheduledObjectsForSequentialPrintability(const SolverConfiguration
|
||||
const std::vector<ObjectToPrint> &objects_to_print,
|
||||
const std::vector<ScheduledPlate> &scheduled_plates);
|
||||
|
||||
/*
|
||||
This is a variant of the interface for checking sequential printability.
|
||||
|
||||
If not sequentially printable returns a pair of object IDs that are in conflict,
|
||||
that is, when the second object is printed the extruder will collide with the
|
||||
first object. The returned conflict is not necessarily the first collision to
|
||||
occur when printing the object according to the given input schedule.
|
||||
|
||||
Note: The function always succeeds, does not throw any exception.
|
||||
*/
|
||||
std::optional<std::pair<int, int> > check_ScheduledObjectsForSequentialConflict(const SolverConfiguration &solver_configuration,
|
||||
const PrinterGeometry &printer_geometry,
|
||||
const std::vector<ObjectToPrint> &objects_to_print,
|
||||
const std::vector<ScheduledPlate> &scheduled_plates);
|
||||
|
||||
|
||||
/*----------------------------------------------------------------*/
|
||||
/*
|
||||
@ -160,15 +175,13 @@ 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,
|
||||
std::function<void(int)> progress_callback = [](int progress){},
|
||||
bool trans_bed_glue = false);
|
||||
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::function<void(int)> progress_callback = [](int progress){},
|
||||
bool trans_bed_glue = false);
|
||||
std::function<void(int)> progress_callback = [](int progress){});
|
||||
|
||||
|
||||
/*----------------------------------------------------------------*/
|
||||
@ -179,8 +192,7 @@ 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::function<void(int)> progress_callback = [](int progress){},
|
||||
bool trans_bed_glue = false);
|
||||
std::function<void(int)> progress_callback = [](int progress){});
|
||||
|
||||
void setup_ExtruderUnreachableZones(const SolverConfiguration &solver_configuration,
|
||||
std::vector<std::vector<Slic3r::Polygon> > &convex_unreachable_zones,
|
||||
@ -191,8 +203,7 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration
|
||||
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::function<void(int)> progress_callback = [](int progress){},
|
||||
bool trans_bed_glue = false);
|
||||
std::function<void(int)> progress_callback = [](int progress){});
|
||||
|
||||
|
||||
/*----------------------------------------------------------------*/
|
||||
|
@ -176,10 +176,27 @@ void SolverConfiguration::set_ObjectGroupSize(int _object_group_size)
|
||||
|
||||
/*----------------------------------------------------------------*/
|
||||
|
||||
|
||||
bool check_ScheduledObjectsForSequentialPrintability(const SolverConfiguration &solver_configuration,
|
||||
const PrinterGeometry &printer_geometry,
|
||||
const std::vector<ObjectToPrint> &objects_to_print,
|
||||
const std::vector<ScheduledPlate> &scheduled_plates)
|
||||
{
|
||||
if (check_ScheduledObjectsForSequentialConflict(solver_configuration,
|
||||
printer_geometry,
|
||||
objects_to_print,
|
||||
scheduled_plates))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
std::optional<std::pair<int, int> > check_ScheduledObjectsForSequentialConflict(const SolverConfiguration &solver_configuration,
|
||||
const PrinterGeometry &printer_geometry,
|
||||
const std::vector<ObjectToPrint> &objects_to_print,
|
||||
const std::vector<ScheduledPlate> &scheduled_plates)
|
||||
{
|
||||
std::vector<Slic3r::Polygon> polygons;
|
||||
std::vector<std::vector<Slic3r::Polygon> > unreachable_polygons;
|
||||
@ -270,13 +287,13 @@ bool check_ScheduledObjectsForSequentialPrintability(const SolverConfiguration
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!check_PointsOutsidePolygons(dec_values_X,
|
||||
dec_values_Y,
|
||||
dec_values_T,
|
||||
plate_polygons,
|
||||
plate_unreachable_polygons))
|
||||
if (auto conflict = check_PointsOutsidePolygons(dec_values_X,
|
||||
dec_values_Y,
|
||||
dec_values_T,
|
||||
plate_polygons,
|
||||
plate_unreachable_polygons))
|
||||
{
|
||||
return false;
|
||||
return std::pair<int, int>(objects_to_print[conflict.value().first].id, objects_to_print[conflict.value().second].id);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
{
|
||||
@ -290,13 +307,13 @@ bool check_ScheduledObjectsForSequentialPrintability(const SolverConfiguration
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!check_PolygonLineIntersections(dec_values_X,
|
||||
dec_values_Y,
|
||||
dec_values_T,
|
||||
plate_polygons,
|
||||
plate_unreachable_polygons))
|
||||
if (auto conflict = check_PolygonLineIntersections(dec_values_X,
|
||||
dec_values_Y,
|
||||
dec_values_T,
|
||||
plate_polygons,
|
||||
plate_unreachable_polygons))
|
||||
{
|
||||
return false;
|
||||
return std::pair<int, int>(objects_to_print[conflict.value().first].id, objects_to_print[conflict.value().second].id);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
{
|
||||
@ -310,7 +327,7 @@ bool check_ScheduledObjectsForSequentialPrintability(const SolverConfiguration
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
@ -319,8 +336,7 @@ 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,
|
||||
std::function<void(int)> progress_callback,
|
||||
bool trans_bed_glue)
|
||||
std::function<void(int)> progress_callback)
|
||||
{
|
||||
std::vector<ScheduledPlate> scheduled_plates;
|
||||
|
||||
@ -328,8 +344,7 @@ std::vector<ScheduledPlate> schedule_ObjectsForSequentialPrint(const SolverConfi
|
||||
printer_geometry,
|
||||
objects_to_print,
|
||||
scheduled_plates,
|
||||
progress_callback,
|
||||
trans_bed_glue);
|
||||
progress_callback);
|
||||
return scheduled_plates;
|
||||
}
|
||||
|
||||
@ -351,8 +366,7 @@ void schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver
|
||||
const PrinterGeometry &printer_geometry,
|
||||
const std::vector<ObjectToPrint> &objects_to_print,
|
||||
std::vector<ScheduledPlate> &scheduled_plates,
|
||||
std::function<void(int)> progress_callback,
|
||||
bool trans_bed_glue)
|
||||
std::function<void(int)> progress_callback)
|
||||
{
|
||||
#ifdef PROFILE
|
||||
clock_t start, finish;
|
||||
@ -424,7 +438,7 @@ void schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver
|
||||
int progress_object_phases_done = 0;
|
||||
int progress_object_phases_total = SEQ_MAKE_EXTRA_PROGRESS((objects_to_print.size() * SEQ_PROGRESS_PHASES_PER_OBJECT));
|
||||
|
||||
bool trans_bed_lepox = trans_bed_glue;
|
||||
bool trans_bed_lepox = false;
|
||||
|
||||
do
|
||||
{
|
||||
@ -591,8 +605,7 @@ 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::function<void(int)> progress_callback,
|
||||
bool trans_bed_glue)
|
||||
std::function<void(int)> progress_callback)
|
||||
{
|
||||
#ifdef PROFILE
|
||||
clock_t start, finish;
|
||||
@ -842,7 +855,7 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_
|
||||
int progress_object_phases_done = 0;
|
||||
int progress_object_phases_total = SEQ_MAKE_EXTRA_PROGRESS((objects_to_print.size() * SEQ_PROGRESS_PHASES_PER_OBJECT));
|
||||
|
||||
bool trans_bed_lepox = trans_bed_glue;
|
||||
bool trans_bed_lepox = false;
|
||||
|
||||
do
|
||||
{
|
||||
@ -1044,8 +1057,7 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration
|
||||
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::function<void(int)> progress_callback,
|
||||
bool trans_bed_glue)
|
||||
std::function<void(int)> progress_callback)
|
||||
{
|
||||
#ifdef PROFILE
|
||||
clock_t start, finish;
|
||||
@ -1181,7 +1193,7 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration
|
||||
int progress_object_phases_done = 0;
|
||||
int progress_object_phases_total = SEQ_MAKE_EXTRA_PROGRESS((objects_to_print.size() * SEQ_PROGRESS_PHASES_PER_OBJECT));
|
||||
|
||||
bool trans_bed_lepox = trans_bed_glue;
|
||||
bool trans_bed_lepox = false;
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -6443,11 +6443,11 @@ bool refine_ConsequentialPolygonWeakNonoverlapping(z3::solver
|
||||
|
||||
/*----------------------------------------------------------------*/
|
||||
|
||||
bool check_PointsOutsidePolygons(const std::vector<Rational> &dec_values_X,
|
||||
const std::vector<Rational> &dec_values_Y,
|
||||
const std::vector<Rational> &dec_values_T,
|
||||
const std::vector<Slic3r::Polygon> &polygons,
|
||||
const std::vector<std::vector<Slic3r::Polygon> > &unreachable_polygons)
|
||||
std::optional<std::pair<int, int> > check_PointsOutsidePolygons(const std::vector<Rational> &dec_values_X,
|
||||
const std::vector<Rational> &dec_values_Y,
|
||||
const std::vector<Rational> &dec_values_T,
|
||||
const std::vector<Slic3r::Polygon> &polygons,
|
||||
const std::vector<std::vector<Slic3r::Polygon> > &unreachable_polygons)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
{
|
||||
@ -6653,7 +6653,7 @@ bool check_PointsOutsidePolygons(const std::vector<Rational>
|
||||
}
|
||||
if (always_inside_halfplane)
|
||||
{
|
||||
return false;
|
||||
return std::pair<int, int>(j, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6716,7 +6716,7 @@ bool check_PointsOutsidePolygons(const std::vector<Rational>
|
||||
}
|
||||
if (always_inside_halfplane)
|
||||
{
|
||||
return false;
|
||||
return std::pair<int, int>(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6740,15 +6740,15 @@ bool check_PointsOutsidePolygons(const std::vector<Rational>
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
bool check_PolygonLineIntersections(const std::vector<Rational> &dec_values_X,
|
||||
const std::vector<Rational> &dec_values_Y,
|
||||
const std::vector<Rational> &dec_values_T,
|
||||
const std::vector<Slic3r::Polygon> &polygons,
|
||||
const std::vector<std::vector<Slic3r::Polygon> > &unreachable_polygons)
|
||||
std::optional<std::pair<int, int> > check_PolygonLineIntersections(const std::vector<Rational> &dec_values_X,
|
||||
const std::vector<Rational> &dec_values_Y,
|
||||
const std::vector<Rational> &dec_values_T,
|
||||
const std::vector<Slic3r::Polygon> &polygons,
|
||||
const std::vector<std::vector<Slic3r::Polygon> > &unreachable_polygons)
|
||||
{
|
||||
if (!polygons.empty())
|
||||
{
|
||||
@ -6814,7 +6814,7 @@ bool check_PolygonLineIntersections(const std::vector<Rational>
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
return std::pair<int, int>(j, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6878,7 +6878,7 @@ bool check_PolygonLineIntersections(const std::vector<Rational>
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
return std::pair<int, int>(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6904,7 +6904,7 @@ bool check_PolygonLineIntersections(const std::vector<Rational>
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
|
@ -1223,17 +1223,17 @@ bool refine_ConsequentialPolygonWeakNonoverlapping(z3::solver
|
||||
|
||||
/*----------------------------------------------------------------*/
|
||||
|
||||
bool check_PointsOutsidePolygons(const std::vector<Rational> &dec_values_X,
|
||||
const std::vector<Rational> &dec_values_Y,
|
||||
const std::vector<Rational> &dec_values_T,
|
||||
const std::vector<Slic3r::Polygon> &polygons,
|
||||
const std::vector<std::vector<Slic3r::Polygon> > &unreachable_polygons);
|
||||
std::optional<std::pair<int, int> > check_PointsOutsidePolygons(const std::vector<Rational> &dec_values_X,
|
||||
const std::vector<Rational> &dec_values_Y,
|
||||
const std::vector<Rational> &dec_values_T,
|
||||
const std::vector<Slic3r::Polygon> &polygons,
|
||||
const std::vector<std::vector<Slic3r::Polygon> > &unreachable_polygons);
|
||||
|
||||
bool check_PolygonLineIntersections(const std::vector<Rational> &dec_values_X,
|
||||
const std::vector<Rational> &dec_values_Y,
|
||||
const std::vector<Rational> &dec_values_T,
|
||||
const std::vector<Slic3r::Polygon> &polygons,
|
||||
const std::vector<std::vector<Slic3r::Polygon> > &unreachable_polygons);
|
||||
std::optional<std::pair<int, int> > check_PolygonLineIntersections(const std::vector<Rational> &dec_values_X,
|
||||
const std::vector<Rational> &dec_values_Y,
|
||||
const std::vector<Rational> &dec_values_T,
|
||||
const std::vector<Slic3r::Polygon> &polygons,
|
||||
const std::vector<std::vector<Slic3r::Polygon> > &unreachable_polygons);
|
||||
|
||||
|
||||
/*----------------------------------------------------------------*/
|
||||
|
@ -338,10 +338,17 @@ void SeqArrange::apply_seq_arrange(Model& model) const
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool check_seq_printability(const Model& model, const ConfigBase& config)
|
||||
{
|
||||
if (auto conflict = check_seq_conflict(model, config))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
std::optional<std::pair<int, int> > check_seq_conflict(const Model& model, const ConfigBase& config)
|
||||
{
|
||||
Sequential::PrinterGeometry printer_geometry = get_printer_geometry(config);
|
||||
Sequential::SolverConfiguration solver_config = get_solver_config(printer_geometry);
|
||||
@ -350,7 +357,7 @@ bool check_seq_printability(const Model& model, const ConfigBase& config)
|
||||
if (printer_geometry.extruder_slices.empty()) {
|
||||
// If there are no data for extruder (such as extruder_clearance_radius set to 0),
|
||||
// consider it printable.
|
||||
return true;
|
||||
return {};
|
||||
}
|
||||
|
||||
Sequential::ScheduledPlate plate;
|
||||
@ -373,7 +380,8 @@ bool check_seq_printability(const Model& model, const ConfigBase& config)
|
||||
}
|
||||
}
|
||||
|
||||
return Sequential::check_ScheduledObjectsForSequentialPrintability(solver_config, printer_geometry, objects, std::vector<Sequential::ScheduledPlate>(1, plate));
|
||||
//return Sequential::check_ScheduledObjectsForSequentialPrintability(solver_config, printer_geometry, objects, std::vector<Sequential::ScheduledPlate>(1, plate));
|
||||
return Sequential::check_ScheduledObjectsForSequentialConflict(solver_config, printer_geometry, objects, std::vector<Sequential::ScheduledPlate>(1, plate));
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,7 +14,9 @@ namespace Slic3r {
|
||||
class ExceptionCannotApplySeqArrange : public std::exception {};
|
||||
|
||||
void arrange_model_sequential(Model& model, const ConfigBase& config);
|
||||
|
||||
bool check_seq_printability(const Model& model, const ConfigBase& config);
|
||||
std::optional<std::pair<int, int> > check_seq_conflict(const Model& model, const ConfigBase& config);
|
||||
|
||||
// This is just a helper class to collect data for seq. arrangement, running the arrangement
|
||||
// and applying the results to model. It is here so the processing itself can be offloaded
|
||||
|
Loading…
x
Reference in New Issue
Block a user