NEW: add nozzle_height to machine profile and do not detect conflict

Jira: request from 1.9

1. add nozzle_height to machine profile
2. auto arranging and sequential_print_clearance_valid don't consider objects conflicting if they are all shorter than nozzle_height and close.
3. do not detect conflict when all models are short.

Change-Id: I8d1eebb15d5bfa8c40d7491e033149e360531b89
(cherry picked from commit 6b4b52653db5f08d724a556c5c766c0bfa00f34d)
This commit is contained in:
Arthur 2023-12-19 20:05:04 +08:00 committed by Lane.Wei
parent 8de8f84c96
commit 472640c1f1
10 changed files with 41 additions and 10 deletions

View File

@ -101,8 +101,14 @@ void update_selected_items_inflation(ArrangePolygons& selected, const DynamicPri
Points bedpts = get_shrink_bedpts(print_cfg, params);
BoundingBox bedbb = Polygon(bedpts).bounding_box();
// set obj distance for auto seq_print
if (params.min_obj_distance == 0 && params.is_seq_print)
params.min_obj_distance = scaled(params.cleareance_radius + 0.001);
if (params.is_seq_print) {
bool all_objects_are_short = std::all_of(selected.begin(), selected.end(), [&](ArrangePolygon& ap) { return ap.height < params.nozzle_height; });
if (all_objects_are_short) {
params.min_obj_distance = std::max(params.min_obj_distance, scaled(double(MAX_OUTER_NOZZLE_DIAMETER)/2+0.001));
}
else
params.min_obj_distance = std::max(params.min_obj_distance, scaled(params.cleareance_radius + 0.001)); // +0.001mm to avoid clearance check fail due to rounding error
}
double brim_max = 0;
bool plate_has_tree_support = false;
std::for_each(selected.begin(), selected.end(), [&](ArrangePolygon& ap) {

View File

@ -132,6 +132,7 @@ struct ArrangeParams {
float clearance_height_to_rod = 0;
float clearance_height_to_lid = 0;
float cleareance_radius = 0;
float nozzle_height = 0;
float printable_height = 256.0;
Vec2d align_center{ 0.5,0.5 };

View File

@ -887,6 +887,7 @@ static std::vector<std::string> s_Preset_printer_options {
"printable_area", "bed_exclude_area","bed_custom_texture", "bed_custom_model", "gcode_flavor",
"single_extruder_multi_material", "machine_start_gcode", "machine_end_gcode","printing_by_object_gcode","before_layer_change_gcode", "layer_change_gcode", "time_lapse_gcode", "change_filament_gcode",
"printer_model", "printer_variant", "printable_height", "extruder_clearance_radius", "extruder_clearance_max_radius","extruder_clearance_height_to_lid", "extruder_clearance_height_to_rod",
"nozzle_height",
"default_print_profile", "inherits",
"silent_mode",
// BBS

View File

@ -101,6 +101,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
"extruder_clearance_height_to_rod",
"extruder_clearance_height_to_lid",
"extruder_clearance_radius",
"nozzle_height",
"extruder_clearance_max_radius",
"extruder_colour",
"extruder_offset",
@ -515,6 +516,11 @@ StringObjectException Print::sequential_print_clearance_valid(const Print &print
polygons->clear();
std::vector<size_t> intersecting_idxs;
bool all_objects_are_short = std::all_of(print.objects().begin(), print.objects().end(), [&](PrintObject* obj) { return obj->height() < scale_(print.config().nozzle_height.value - MARGIN_HEIGHT); });
// Shrink the extruder_clearance_radius a tiny bit, so that if the object arrangement algorithm placed the objects
// exactly by satisfying the extruder_clearance_radius, this test will not trigger collision.
float obj_distance = all_objects_are_short ? scale_(0.5*MAX_OUTER_NOZZLE_DIAMETER-0.1) : scale_(0.5*print.config().extruder_clearance_radius.value-0.1);
for (const PrintObject *print_object : print.objects()) {
assert(! print_object->model_object()->instances.empty());
assert(! print_object->instances().empty());
@ -540,11 +546,7 @@ StringObjectException Print::sequential_print_clearance_valid(const Print &print
// Now we check that no instance of convex_hull intersects any of the previously checked object instances.
for (const PrintInstance &instance : print_object->instances()) {
Polygon convex_hull_no_offset = convex_hull0, convex_hull;
auto tmp = offset(convex_hull_no_offset,
// Shrink the extruder_clearance_radius a tiny bit, so that if the object arrangement algorithm placed the objects
// exactly by satisfying the extruder_clearance_radius, this test will not trigger collision.
float(scale_(0.5 * print.config().extruder_clearance_max_radius.value - 0.1)),
jtRound, scale_(0.1));
auto tmp = offset(convex_hull_no_offset, obj_distance, jtRound, scale_(0.1));
if (!tmp.empty()) { // tmp may be empty due to clipper's bug, see STUDIO-2452
convex_hull = tmp.front();
// instance.shift is a position of a centered object, while model object may not be centered.

View File

@ -35,6 +35,8 @@ class SupportLayer;
class TreeSupportData;
class TreeSupport;
#define MARGIN_HEIGHT 1.5
#define MAX_OUTER_NOZZLE_DIAMETER 4
// BBS: move from PrintObjectSlice.cpp
struct VolumeSlices
{

View File

@ -1254,6 +1254,14 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(40));
def = this->add("nozzle_height", coFloat);
def->label = L("Nozzle height");
def->tooltip = L("The height of nozzle tip.");
def->sidetext = L("mm");
def->min = 0;
def->mode = comDevelop;
def->set_default_value(new ConfigOptionFloat(4));
def = this->add("extruder_clearance_max_radius", coFloat);
def->label = L("Max Radius");
def->tooltip = L("Max clearance radius around extruder. Used for collision avoidance in by-object printing.");
@ -4992,6 +5000,8 @@ std::map<std::string, std::string> validate(const FullPrintConfig &cfg, bool und
if (cfg.extruder_clearance_height_to_lid <= 0) {
error_message.emplace("extruder_clearance_height_to_lid", L("invalid value ") + std::to_string(cfg.extruder_clearance_height_to_lid));
}
if (cfg.nozzle_height <= 0)
error_message.emplace("nozzle_height", L("invalid value ") + std::to_string(cfg.nozzle_height));
// --extrusion-multiplier
for (double em : cfg.filament_flow_ratio.values)

View File

@ -968,6 +968,7 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE(
((ConfigOptionFloat, extruder_clearance_height_to_rod))//BBs
((ConfigOptionFloat, extruder_clearance_height_to_lid))//BBS
((ConfigOptionFloat, extruder_clearance_radius))
((ConfigOptionFloat, nozzle_height))
((ConfigOptionFloat, extruder_clearance_max_radius))
((ConfigOptionStrings, extruder_colour))
((ConfigOptionPoints, extruder_offset))

View File

@ -5085,7 +5085,14 @@ void GLCanvas3D::update_sequential_clearance()
// the results are then cached for following displacements
if (m_sequential_print_clearance_first_displacement) {
m_sequential_print_clearance.m_hull_2d_cache.clear();
float shrink_factor = static_cast<float>(scale_(0.5 * fff_print()->config().extruder_clearance_max_radius.value - EPSILON));
bool all_objects_are_short = std::all_of(fff_print()->objects().begin(), fff_print()->objects().end(), \
[&](PrintObject* obj) { return obj->height() < scale_(fff_print()->config().nozzle_height.value - MARGIN_HEIGHT); });
float shrink_factor;
if (all_objects_are_short)
shrink_factor = scale_(0.5 * MAX_OUTER_NOZZLE_DIAMETER - 0.1);
else
shrink_factor = static_cast<float>(scale_(0.5 * fff_print()->config().extruder_clearance_max_radius.value - EPSILON));
double mitter_limit = scale_(0.1);
m_sequential_print_clearance.m_hull_2d_cache.reserve(m_model->objects.size());
for (size_t i = 0; i < m_model->objects.size(); ++i) {

View File

@ -768,6 +768,7 @@ arrangement::ArrangeParams init_arrange_params(Plater *p)
params.clearance_height_to_lid = print_config.extruder_clearance_height_to_lid.value;
params.cleareance_radius = print_config.extruder_clearance_max_radius.value;
params.printable_height = print_config.printable_height.value;
params.nozzle_height = print.config().nozzle_height.value;
params.align_center = print_config.best_object_pos.value;
params.allow_rotations = settings.enable_rotation;
params.allow_multi_materials_on_same_plate = settings.allow_multi_materials_on_same_plate;
@ -788,7 +789,6 @@ arrangement::ArrangeParams init_arrange_params(Plater *p)
}
if (params.is_seq_print) {
params.min_obj_distance = std::max(params.min_obj_distance, scaled(params.cleareance_radius + 0.001)); // +0.001mm to avoid clearance check fail due to rounding error
params.bed_shrink_x = BED_SHRINK_SEQ_PRINT;
params.bed_shrink_y = BED_SHRINK_SEQ_PRINT;
}

View File

@ -2647,7 +2647,8 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
, config(Slic3r::DynamicPrintConfig::new_from_defaults_keys({
"printable_area", "bed_exclude_area", "bed_custom_texture", "bed_custom_model", "print_sequence",
"extruder_clearance_radius", "extruder_clearance_max_radius",
"extruder_clearance_height_to_lid", "extruder_clearance_height_to_rod", "skirt_loops", "skirt_distance",
"extruder_clearance_height_to_lid", "extruder_clearance_height_to_rod",
"nozzle_height", "skirt_loops", "skirt_distance",
"brim_width", "brim_object_gap", "brim_type", "nozzle_diameter", "single_extruder_multi_material",
"enable_prime_tower", "wipe_tower_x", "wipe_tower_y", "prime_tower_width", "prime_tower_brim_width", "prime_volume",
"extruder_colour", "filament_colour", "material_colour", "printable_height", "printer_model", "printer_technology",