mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 07:27:41 -06:00
FIX: FillBed crashes when accessing unset print config option
1. When the option is not set, print.full_print_config() is empty, so we can't access opt_bool("scan_first_layer") or opt_bool("enable_support"). Should use wxGetApp().preset_bundle->full_config() instead. Jira: STUDIO-3264 2. Allow different object having different brim_width to encode support's brim width. In this way the arranging logic is simpler and more objects can be arranged in a plate. Change-Id: Ic7178652147b0519d50b2eb9ceb214b4ef4c0251 (cherry picked from commit 0f163d59b40009cd29b8b1e32f730258ad0786dc)
This commit is contained in:
parent
9ad9ba213a
commit
4e5f4ee366
3 changed files with 15 additions and 15 deletions
|
@ -157,6 +157,11 @@ ArrangePolygon get_instance_arrange_poly(ModelInstance* instance, const Slic3r::
|
|||
}
|
||||
#else
|
||||
ap.brim_width = 0;
|
||||
// For by-layer printing, need to shrink bed a little, so the support won't go outside bed.
|
||||
// We set it to 5mm because that's how much a normal support will grow by default.
|
||||
auto supp_type_ptr = obj->get_config_value<ConfigOptionBool>(config, "enable_support");
|
||||
if (supp_type_ptr && supp_type_ptr->getBool())
|
||||
ap.brim_width = 5.0;
|
||||
#endif
|
||||
|
||||
ap.height = obj->bounding_box().size().z();
|
||||
|
|
|
@ -497,7 +497,8 @@ void ArrangeJob::process()
|
|||
auto & partplate_list = m_plater->get_partplate_list();
|
||||
auto& print = wxGetApp().plater()->get_partplate_list().get_current_fff_print();
|
||||
|
||||
if (params.avoid_extrusion_cali_region && print.full_print_config().opt_bool("scan_first_layer"))
|
||||
const Slic3r::DynamicPrintConfig& global_config = wxGetApp().preset_bundle->full_config();
|
||||
if (params.avoid_extrusion_cali_region && global_config.opt_bool("scan_first_layer"))
|
||||
partplate_list.preprocess_nonprefered_areas(m_unselected, MAX_NUM_PLATES);
|
||||
|
||||
update_arrange_params(params, *m_plater, m_selected);
|
||||
|
@ -776,15 +777,6 @@ void update_arrange_params(arrangement::ArrangeParams ¶ms, const Plater &p,
|
|||
params.bed_shrink_x -= shift_dist;
|
||||
params.bed_shrink_y -= shift_dist;
|
||||
}
|
||||
|
||||
// For by-layer printing, need to shrink bed a little, so the support won't go outside bed.
|
||||
// We set it to 5mm because that's how much a normal support will grow by default.
|
||||
// But for by-object printing, it's not needed since the clerance distance is already very large.
|
||||
if (print.full_print_config().opt_bool("enable_support") && !params.is_seq_print) {
|
||||
params.bed_shrink_x = std::max(5.f, params.bed_shrink_x);
|
||||
params.bed_shrink_y = std::max(5.f, params.bed_shrink_y);
|
||||
params.min_obj_distance = std::max(scaled(10.0), params.min_obj_distance);
|
||||
}
|
||||
}
|
||||
|
||||
//it will bed accurate after call update_params
|
||||
|
@ -807,7 +799,7 @@ void update_selected_items_inflation(arrangement::ArrangePolygons &selected, con
|
|||
Points bedpts = get_shrink_bedpts(p, params);
|
||||
BoundingBox bedbb = Polygon(bedpts).bounding_box();
|
||||
std::for_each(selected.begin(), selected.end(), [&](ArrangePolygon &ap) {
|
||||
ap.inflation = params.min_obj_distance / 2;
|
||||
ap.inflation = std::max(scaled(ap.brim_width), params.min_obj_distance / 2);
|
||||
BoundingBox apbb = ap.poly.contour.bounding_box();
|
||||
auto diffx = bedbb.size().x() - apbb.size().x() - 5;
|
||||
auto diffy = bedbb.size().y() - apbb.size().y() - 5;
|
||||
|
@ -834,7 +826,8 @@ void update_unselected_items_inflation(arrangement::ArrangePolygons &unselected,
|
|||
// 其他物体的膨胀轮廓是可以跟它们重叠的。
|
||||
double scaled_exclusion_gap = scale_(1);
|
||||
std::for_each(unselected.begin(), unselected.end(),
|
||||
[&](auto &ap) { ap.inflation = !ap.is_virt_object ? params.min_obj_distance / 2 : (ap.is_extrusion_cali_object ? 0 : scaled_exclusion_gap); });
|
||||
[&](auto &ap) { ap.inflation = !ap.is_virt_object ? std::max(scaled(ap.brim_width), params.min_obj_distance / 2)
|
||||
: (ap.is_extrusion_cali_object ? 0 : scaled_exclusion_gap); });
|
||||
}
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
|
|
@ -45,6 +45,7 @@ void FillBedJob::prepare()
|
|||
ModelObject *model_object = m_plater->model().objects[m_object_idx];
|
||||
if (model_object->instances.empty()) return;
|
||||
|
||||
const Slic3r::DynamicPrintConfig& global_config = wxGetApp().preset_bundle->full_config();
|
||||
m_selected.reserve(model_object->instances.size());
|
||||
for (size_t oidx = 0; oidx < model.objects.size(); ++oidx)
|
||||
{
|
||||
|
@ -53,7 +54,7 @@ void FillBedJob::prepare()
|
|||
{
|
||||
bool selected = (oidx == m_object_idx);
|
||||
|
||||
ArrangePolygon ap = get_arrange_poly(mo->instances[inst_idx]);
|
||||
ArrangePolygon ap = get_instance_arrange_poly(mo->instances[inst_idx], global_config);
|
||||
BoundingBox ap_bb = ap.transformed_poly().contour.bounding_box();
|
||||
ap.height = 1;
|
||||
ap.name = mo->name;
|
||||
|
@ -167,7 +168,7 @@ void FillBedJob::prepare()
|
|||
// if the selection is not a single instance, choose the first as template
|
||||
//sel_id = std::max(sel_id, 0);
|
||||
ModelInstance *mi = model_object->instances[sel_id];
|
||||
ArrangePolygon template_ap = get_arrange_poly(mi);
|
||||
ArrangePolygon template_ap = get_instance_arrange_poly(mi, global_config);
|
||||
|
||||
for (int i = 0; i < needed_items; ++i) {
|
||||
ArrangePolygon ap = template_ap;
|
||||
|
@ -209,7 +210,8 @@ void FillBedJob::process()
|
|||
|
||||
auto &partplate_list = m_plater->get_partplate_list();
|
||||
auto &print = wxGetApp().plater()->get_partplate_list().get_current_fff_print();
|
||||
if (params.avoid_extrusion_cali_region && print.full_print_config().opt_bool("scan_first_layer"))
|
||||
const Slic3r::DynamicPrintConfig& global_config = wxGetApp().preset_bundle->full_config();
|
||||
if (params.avoid_extrusion_cali_region && global_config.opt_bool("scan_first_layer"))
|
||||
partplate_list.preprocess_nonprefered_areas(m_unselected, MAX_NUM_PLATES);
|
||||
|
||||
update_selected_items_inflation(m_selected, *m_plater, params);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue