add complete_objects_one_brim

* now takes into account per-object brim for auto-arrange & complete_object check
* complete_objects_one_brim allow to print the brim first to remove it from the complete_object check & arrange
This commit is contained in:
remi durand 2021-06-08 18:50:18 +02:00
parent 4ed4ec0151
commit f5dd619c53
8 changed files with 45 additions and 20 deletions

View File

@ -348,6 +348,7 @@ group:Plater
group:Sequential printing
setting:complete_objects
setting:complete_objects_one_skirt
setting:complete_objects_one_brim
setting:complete_objects_sort
line:Extruder clearance (mm)
setting:width$6:extruder_clearance_radius

View File

@ -531,6 +531,7 @@ const std::vector<std::string>& Preset::print_options()
, "support_material_buildplate_only", "dont_support_bridges", "notes",
"complete_objects",
"complete_objects_one_skirt",
"complete_objects_one_brim",
"complete_objects_sort",
"extruder_clearance_radius",
"extruder_clearance_height", "gcode_comments", "gcode_label_objects", "output_filename_format", "post_process", "perimeter_extruder",

View File

@ -202,6 +202,7 @@ bool Print::invalidate_state_by_config_options(const std::vector<t_config_option
|| opt_key == "skirt_distance"
|| opt_key == "min_skirt_length"
|| opt_key == "complete_objects_one_skirt"
|| opt_key == "complete_objects_one_brim"
|| opt_key == "ooze_prevention"
|| opt_key == "wipe_tower_x"
|| opt_key == "wipe_tower_y"
@ -1275,8 +1276,9 @@ static inline bool sequential_print_horizontal_clearance_valid(const Print &prin
{
Polygons convex_hulls_other;
std::map<ObjectID, Polygon> map_model_object_to_convex_hull;
const double dist_grow = PrintConfig::min_object_distance(&print.default_region_config());
for (const PrintObject *print_object : print.objects()) {
double dist_grow = PrintConfig::min_object_distance(&print_object->config());
const double object_grow = print.config().complete_objects_one_brim ? dist_grow : std::max(dist_grow, print_object->config().brim_width.value);
assert(! print_object->model_object()->instances.empty());
assert(! print_object->instances().empty());
ObjectID model_object_id = print_object->model_object()->id();
@ -1294,7 +1296,7 @@ static inline bool sequential_print_horizontal_clearance_valid(const Print &prin
Geometry::assemble_transform(Vec3d::Zero(), model_instance0->get_rotation(), model_instance0->get_scaling_factor(), model_instance0->get_mirror())),
// 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 * dist_grow - EPSILON)),
float(scale_(0.5 * object_grow - EPSILON)),
jtRound, float(scale_(0.1))).front());
}
// Make a copy, so it may be rotated for instances.
@ -1803,7 +1805,7 @@ void Print::process()
const PrintObjectConfig &brim_config = obj_group.front()->config();
if (brim_config.brim_width > 0 || brim_config.brim_width_interior > 0) {
this->set_status(88, L("Generating brim"));
if (config().complete_objects) {
if (config().complete_objects && !config().complete_objects_one_brim) {
for (PrintObject *obj : obj_group) {
//get flow
std::vector<uint16_t> set_extruders = this->object_extruders({ obj });

View File

@ -575,6 +575,14 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionBool(false));
def = this->add("complete_objects_one_brim", coBool);
def->label = L("Print all brim at startup");
def->category = OptionCategory::output;
def->tooltip = L("When using 'Complete individual objects', the default behavior is to draw the brim at the beginning of each object."
" if you prefer to have more place for you objects, you can print all the brims at the beginning, so ther is less problem with collision.");
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionBool(false));
def = this->add("complete_objects_sort", coEnum);
def->label = L("Object sort");
def->category = OptionCategory::output;
@ -5381,6 +5389,7 @@ void PrintConfigDef::to_prusa(t_config_option_key& opt_key, std::string& value,
"brim_offset",
"chamber_temperature",
"complete_objects_one_skirt",
"complete_objects_one_brim",
"complete_objects_sort",
"top_fill_pattern",
"solid_fill_pattern",
@ -5662,7 +5671,6 @@ double PrintConfig::min_object_distance(const ConfigBase *config, double ref_hei
//std::cout << "START min_object_distance =>" << base_dist << "\n";
const ConfigOptionBool* co_opt = config->option<ConfigOptionBool>("complete_objects");
if (co_opt && co_opt->value) {
double brim_dist = 0;
double skirt_dist = 0;
try {
std::vector<double> vals = dynamic_cast<const ConfigOptionFloats*>(config->option("nozzle_diameter"))->values;
@ -5677,18 +5685,7 @@ double PrintConfig::min_object_distance(const ConfigBase *config, double ref_hei
base_dist = extruder_clearance_radius;
}
//add brim width
// note: now brim can be per-object, so you have to get a different min_object_distance per object
// You should increase/reduce the size of the polygons that have a model-wide setting.
const double first_layer_height = config->get_abs_value("first_layer_height");
if (ref_height <= first_layer_height && ref_height != 0) {
if (config->option("brim_width")->getFloat() > 0) {
brim_dist += config->option("brim_width")->getFloat();
}
}
else //if (config->option("brim_width")->getFloat() + 1 > base_dist) {
base_dist += config->option("brim_width")->getFloat();
//}
//add the skirt
if (config->option("skirts")->getInt() > 0 && config->option("skirt_height")->getInt() >= 1 && !config->option("complete_objects_one_skirt")->getBool()) {
if (ref_height == 0) {
@ -5721,7 +5718,7 @@ double PrintConfig::min_object_distance(const ConfigBase *config, double ref_hei
catch (const std::exception & ex) {
boost::nowide::cerr << ex.what() << std::endl;
}
return base_dist + std::max(skirt_dist, brim_dist);
return base_dist + skirt_dist;
}
return base_dist;
}

View File

@ -1263,6 +1263,7 @@ public:
ConfigOptionInts chamber_temperature;
ConfigOptionBool complete_objects;
ConfigOptionBool complete_objects_one_skirt;
ConfigOptionBool complete_objects_one_brim;
ConfigOptionEnum<CompleteObjectSort> complete_objects_sort;
ConfigOptionFloats colorprint_heights;
ConfigOptionBools cooling;
@ -1358,6 +1359,7 @@ protected:
OPT_PTR(chamber_temperature);
OPT_PTR(complete_objects);
OPT_PTR(complete_objects_one_skirt);
OPT_PTR(complete_objects_one_brim);
OPT_PTR(complete_objects_sort);
OPT_PTR(colorprint_heights);
OPT_PTR(cooling);

View File

@ -483,7 +483,7 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig* config)
bool have_sequential_printing = config->opt_bool("complete_objects");
for (auto el : { /*"extruder_clearance_radius", "extruder_clearance_height",*/ "complete_objects_one_skirt",
"complete_objects_sort"})
"complete_objects_sort", "complete_objects_one_brim"})
toggle_field(el, have_sequential_printing);
bool have_ooze_prevention = config->opt_bool("ooze_prevention");

View File

@ -69,17 +69,36 @@ void ArrangeJob::clear_input()
m_unprintable.reserve(cunprint /* for optional wti */);
}
void add_brim(arrangement::ArrangePolygon &ap, const ModelConfigObject &config, const Plater* plater)
{
if (!plater->config()->option("complete_objects_one_brim")->getBool()) {
// object-brim increase the size of the object
// Should be using the "inflation" field but it's non-functional right now.
coord_t diff = scale_(plater->config()->option("brim_width")->getFloat() - plater->config()->option("extruder_clearance_radius")->getFloat() / 2);
if (config.option("brim_width"))
diff = scale_(config.option("brim_width")->getFloat() - plater->config()->option("extruder_clearance_radius")->getFloat() / 2);
if (diff > 0) {
ExPolygons brimmed = offset_ex(ap.poly, diff);
assert(brimmed.size() == 1);
ap.poly = brimmed[0];
}
}
}
void ArrangeJob::prepare_all() {
clear_input();
for (ModelObject *obj: m_plater->model().objects)
for (ModelInstance *mi : obj->instances) {
ArrangePolygons & cont = mi->printable ? m_selected : m_unprintable;
cont.emplace_back(get_arrange_poly(PtrWrapper{mi}, m_plater));
arrangement::ArrangePolygon &&ap = get_arrange_poly(PtrWrapper{ mi }, m_plater);
add_brim(ap, obj->config, m_plater);
cont.emplace_back(std::move(ap));
}
if (auto wti = get_wipe_tower_arrangepoly(*m_plater))
if (auto wti = get_wipe_tower_arrangepoly(*m_plater)) {
m_selected.emplace_back(std::move(*wti));
}
}
void ArrangeJob::prepare_selected() {
@ -114,7 +133,8 @@ void ArrangeJob::prepare_selected() {
(inst_sel[i] ? m_selected :
m_unselected) :
m_unprintable;
add_brim(ap, model.objects[oidx]->config, m_plater);
cont.emplace_back(std::move(ap));
}
}
@ -124,6 +144,7 @@ void ArrangeJob::prepare_selected() {
auto &cont = m_plater->get_selection().is_wipe_tower() ? m_selected :
m_unselected;
cont.emplace_back(std::move(ap));
}

View File

@ -1978,6 +1978,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
"complete_objects",
"complete_objects_sort",
"complete_objects_one_skirt",
"complete_objects_one_brim",
"duplicate_distance", "extruder_clearance_radius",
"skirt_extrusion_width",
"first_layer_extrusion_width",