Fix tree support bed exclusion area calculation (#9633)

Fix tree support bed exclusion area calculation (SoftFever/OrcaSlicer#9624)
This commit is contained in:
Noisyfox 2025-06-01 13:18:03 +08:00 committed by GitHub
parent c93e321ef0
commit 4ae4634976
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 26 additions and 46 deletions

View file

@ -548,19 +548,11 @@ std::vector<size_t> Print::layers_sorted_for_object(float start, float end, std:
StringObjectException Print::sequential_print_clearance_valid(const Print &print, Polygons *polygons, std::vector<std::pair<Polygon, float>>* height_polygons) StringObjectException Print::sequential_print_clearance_valid(const Print &print, Polygons *polygons, std::vector<std::pair<Polygon, float>>* height_polygons)
{ {
StringObjectException single_object_exception; StringObjectException single_object_exception;
auto print_config = print.config(); const auto& print_config = print.config();
Pointfs excluse_area_points = print_config.bed_exclude_area.values; Polygons exclude_polys = get_bed_excluded_area(print_config);
Polygons exclude_polys;
Polygon exclude_poly;
const Vec3d print_origin = print.get_plate_origin(); const Vec3d print_origin = print.get_plate_origin();
for (int i = 0; i < excluse_area_points.size(); i++) { std::for_each(exclude_polys.begin(), exclude_polys.end(),
auto pt = excluse_area_points[i]; [&print_origin](Polygon& p) { p.translate(scale_(print_origin.x()), scale_(print_origin.y())); });
exclude_poly.points.emplace_back(scale_(pt.x() + print_origin.x()), scale_(pt.y() + print_origin.y()));
if (i % 4 == 3) { // exclude areas are always rectangle
exclude_polys.push_back(exclude_poly);
exclude_poly.points.clear();
}
}
std::map<ObjectID, Polygon> map_model_object_to_convex_hull; std::map<ObjectID, Polygon> map_model_object_to_convex_hull;
struct print_instance_info struct print_instance_info
@ -887,19 +879,11 @@ static StringObjectException layered_print_cleareance_valid(const Print &print,
if (print_instances_ordered.size() < 1) if (print_instances_ordered.size() < 1)
return {}; return {};
auto print_config = print.config(); const auto& print_config = print.config();
Pointfs excluse_area_points = print_config.bed_exclude_area.values; Polygons exclude_polys = get_bed_excluded_area(print_config);
Polygons exclude_polys;
Polygon exclude_poly;
const Vec3d print_origin = print.get_plate_origin(); const Vec3d print_origin = print.get_plate_origin();
for (int i = 0; i < excluse_area_points.size(); i++) { std::for_each(exclude_polys.begin(), exclude_polys.end(),
auto pt = excluse_area_points[i]; [&print_origin](Polygon& p) { p.translate(scale_(print_origin.x()), scale_(print_origin.y())); });
exclude_poly.points.emplace_back(scale_(pt.x() + print_origin.x()), scale_(pt.y() + print_origin.y()));
if (i % 4 == 3) { // exclude areas are always rectangle
exclude_polys.push_back(exclude_poly);
exclude_poly.points.clear();
}
}
std::map<const PrintInstance*, Polygon> map_model_object_to_convex_hull; std::map<const PrintInstance*, Polygon> map_model_object_to_convex_hull;
// sequential_print_horizontal_clearance_valid // sequential_print_horizontal_clearance_valid

View file

@ -8154,22 +8154,27 @@ Points get_bed_shape(const PrintConfig &cfg)
Points get_bed_shape(const SLAPrinterConfig &cfg) { return to_points(make_counter_clockwise(cfg.printable_area.values)); } Points get_bed_shape(const SLAPrinterConfig &cfg) { return to_points(make_counter_clockwise(cfg.printable_area.values)); }
Polygons get_bed_excluded_area(const PrintConfig& cfg)
{
const Pointfs exclude_area_points = cfg.bed_exclude_area.values;
Polygon exclude_poly;
for (int i = 0; i < exclude_area_points.size(); i++) {
auto pt = exclude_area_points[i];
exclude_poly.points.emplace_back(scale_(pt.x()), scale_(pt.y()));
}
exclude_poly.make_counter_clockwise();
return {exclude_poly};
}
Polygon get_bed_shape_with_excluded_area(const PrintConfig& cfg) Polygon get_bed_shape_with_excluded_area(const PrintConfig& cfg)
{ {
Polygon bed_poly; Polygon bed_poly;
bed_poly.points = get_bed_shape(cfg); bed_poly.points = get_bed_shape(cfg);
Points excluse_area_points = to_points(cfg.bed_exclude_area.values); Polygons exclude_polys = get_bed_excluded_area(cfg);
Polygons exclude_polys;
Polygon exclude_poly;
for (int i = 0; i < excluse_area_points.size(); i++) {
auto pt = excluse_area_points[i];
exclude_poly.points.emplace_back(pt);
if (i % 4 == 3) { // exclude areas are always rectangle
exclude_polys.push_back(exclude_poly);
exclude_poly.points.clear();
}
}
auto tmp = diff({ bed_poly }, exclude_polys); auto tmp = diff({ bed_poly }, exclude_polys);
if (!tmp.empty()) bed_poly = tmp[0]; if (!tmp.empty()) bed_poly = tmp[0];
return bed_poly; return bed_poly;

View file

@ -1738,6 +1738,7 @@ bool is_XL_printer(const PrintConfig &cfg);
Points get_bed_shape(const DynamicPrintConfig &cfg); Points get_bed_shape(const DynamicPrintConfig &cfg);
Points get_bed_shape(const PrintConfig &cfg); Points get_bed_shape(const PrintConfig &cfg);
Points get_bed_shape(const SLAPrinterConfig &cfg); Points get_bed_shape(const SLAPrinterConfig &cfg);
Slic3r::Polygons get_bed_excluded_area(const PrintConfig& cfg);
Slic3r::Polygon get_bed_shape_with_excluded_area(const PrintConfig& cfg); Slic3r::Polygon get_bed_shape_with_excluded_area(const PrintConfig& cfg);
bool has_skirt(const DynamicPrintConfig& cfg); bool has_skirt(const DynamicPrintConfig& cfg);
float get_real_skirt_dist(const DynamicPrintConfig& cfg); float get_real_skirt_dist(const DynamicPrintConfig& cfg);

View file

@ -458,17 +458,7 @@ void ArrangeJob::prepare()
auto& print = wxGetApp().plater()->get_partplate_list().get_current_fff_print(); auto& print = wxGetApp().plater()->get_partplate_list().get_current_fff_print();
auto print_config = print.config(); auto print_config = print.config();
bed_poly.points = get_bed_shape(*m_plater->config()); bed_poly.points = get_bed_shape(*m_plater->config());
Pointfs excluse_area_points = print_config.bed_exclude_area.values; Polygons exclude_polys = get_bed_excluded_area(print_config);
Polygons exclude_polys;
Polygon exclude_poly;
for (int i = 0; i < excluse_area_points.size(); i++) {
auto pt = excluse_area_points[i];
exclude_poly.points.emplace_back(scale_(pt.x()), scale_(pt.y()));
if (i % 4 == 3) { // exclude areas are always rectangle
exclude_polys.push_back(exclude_poly);
exclude_poly.points.clear();
}
}
bed_poly = diff({ bed_poly }, exclude_polys)[0]; bed_poly = diff({ bed_poly }, exclude_polys)[0];
} }