Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Jan 4, 2024
2 parents da69166 + 06df1f6 commit dcada9f
Show file tree
Hide file tree
Showing 17 changed files with 142 additions and 96 deletions.
2 changes: 1 addition & 1 deletion resources/localization/fr/Slic3r.po
Original file line number Diff line number Diff line change
Expand Up @@ -11139,7 +11139,7 @@ msgstr "Mode simple"
msgid "Simple widget to enable/disable the overhangs detection (using 55% and 75% for the two thresholds)\nUse the expert mode to get more detailled widgets"
msgstr ""
"Element graphique simplifié pour activer/désactiver la détection des "
"surplombs (utisant 55% et 75% pour els deux seuils)\n"
"surplombs (utisant 55% et 75% pour les deux seuils)\n"
"Utiliser le mode expert permet de modifier les seuils."

msgid "Simulate Prusa 'no thick bridge'"
Expand Down
2 changes: 1 addition & 1 deletion resources/localization/fr/fr_database.po
Original file line number Diff line number Diff line change
Expand Up @@ -11118,7 +11118,7 @@ msgstr "Mode simple"
msgid "Simple widget to enable/disable the overhangs detection (using 55% and 75% for the two thresholds)\nUse the expert mode to get more detailled widgets"
msgstr ""
"Element graphique simplifié pour activer/désactiver la détection des "
"surplombs (utisant 55% et 75% pour els deux seuils)\n"
"surplombs (utisant 55% et 75% pour les deux seuils)\n"
"Utiliser le mode expert permet de modifier les seuils."

msgid "Simulate Prusa 'no thick bridge'"
Expand Down
14 changes: 9 additions & 5 deletions resources/ui_layout/default/print.ui
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ group:Quality
setting:label$_:ensure_vertical_shell_thickness
setting:solid_over_perimeters
end_line
line:Avoid crossing perimeters
setting:label$_:avoid_crossing_perimeters
setting:label_width$12:label$Not on first layer:avoid_crossing_not_first_layer
setting:sidetext_width$15:avoid_crossing_perimeters_max_detour
end_line
line:Overlapping external perimeter
setting:label$_:thin_perimeters
setting:label_width$12:label$Also for all perimeters:thin_perimeters_all
Expand All @@ -52,6 +47,15 @@ group:Quality
setting:width$5:thin_walls_overlap
setting:thin_walls_merge
end_line
group:Avoid crossing perimeters
line:Activate
setting:label$_:avoid_crossing_perimeters
setting:sidetext_width$15:avoid_crossing_perimeters_max_detour
end_line
line:Modifiers
setting:label_width$12:label$Not on first layer:avoid_crossing_not_first_layer
setting:avoid_crossing_top
end_line
group:label_width$12:Overhangs
line:threshold for
setting:script:bool:advanced:depends$overhangs_width_speed$overhangs_width:label$_:label_width$0:tooltip$Simple widget to enable/disable the overhangs detection (using 55% and 75% for the two thresholds)\nUse the expert mode to get more detailled widgets:s_overhangs
Expand Down
17 changes: 17 additions & 0 deletions src/libslic3r/ExtrusionEntity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,23 @@ class GetPathsVisitor : public ExtrusionVisitorRecursive {
}
};


#if _DEBUG
struct LoopAssertVisitor : public ExtrusionVisitorRecursiveConst {
virtual void default_use(const ExtrusionEntity& entity) override {};
virtual void use(const ExtrusionLoop& loop) override {
for (auto it = std::next(loop.paths.begin()); it != loop.paths.end(); ++it) {
assert(it->polyline.size() >= 2);
assert(std::prev(it)->polyline.back() == it->polyline.front());
}
for (auto it = loop.paths.begin(); it != loop.paths.end(); ++it) {
assert(it->length() > SCALED_EPSILON);
}
assert(loop.paths.front().first_point() == loop.paths.back().last_point());
}
};
#endif

}

#endif
34 changes: 27 additions & 7 deletions src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@ void GCode::_do_export(Print& print_mod, GCodeOutputStream &file, ThumbnailsGene

//apply print config to m_config and m_writer, so we don't have to use print.config() instead
// (and mostly to make m_writer.preamble() works)
this->apply_print_config(print.config());
this->apply_print_configs(print);

// modifies m_silent_time_estimator_enabled
DoExport::init_gcode_processor(print.config(), m_processor, m_silent_time_estimator_enabled);
Expand Down Expand Up @@ -2888,6 +2888,7 @@ LayerResult GCode::process_layer(
uint16_t first_extruder_id = layer_tools.extruders.front();

// Initialize config with the 1st object to be printed at this layer.
m_config.apply(print.default_region_config(), true);
m_config.apply(layer.object()->config(), true);

// Check whether it is possible to apply the spiral vase logic for this layer.
Expand Down Expand Up @@ -3197,6 +3198,8 @@ LayerResult GCode::process_layer(
set_extra_lift(m_last_layer_z, layer.id(), print.config(), m_writer, extruder_id);

if (auto loops_it = skirt_loops_per_extruder.find(extruder_id); loops_it != skirt_loops_per_extruder.end()) {
//global skirt & brim use the global settings.
m_config.apply(print.default_object_config(), true);
// before going to and from a global skirt, please ensure you are a a safe height
set_extra_lift(m_last_layer_z, layer.id(), print.config(), m_writer, extruder_id);
const std::pair<size_t, size_t> loops = loops_it->second;
Expand Down Expand Up @@ -3227,6 +3230,8 @@ LayerResult GCode::process_layer(

// Extrude brim with the extruder of the 1st region.
if (! m_brim_done) {
//global skirt & brim use the global settings.
m_config.apply(print.default_object_config(), true);
this->set_origin(0., 0.);
m_avoid_crossing_perimeters.use_external_mp();
for (const ExtrusionEntity* brim_entity : print.brim().entities()) {
Expand All @@ -3248,6 +3253,8 @@ LayerResult GCode::process_layer(
&& extruder_id == layer_tools.extruders.front()) {

const PrintObject *print_object = layers.front().object();
//object skirt & brim use the object settings.
m_config.apply(print_object->config(), true);
this->set_origin(unscale(print_object->instances()[single_object_instance_idx].shift));
if (this->m_layer != nullptr && (this->m_layer->id() < m_config.skirt_height || print.has_infinite_skirt() )) {
if(first_layer && print.skirt_first_layer())
Expand All @@ -3264,6 +3271,8 @@ LayerResult GCode::process_layer(
&& extruder_id == layer_tools.extruders.front()) {

const PrintObject* print_object = layers.front().object();
//object skirt & brim use the object settings.
m_config.apply(print_object->config(), true);
this->set_origin(unscale(print_object->instances()[single_object_instance_idx].shift));
if (this->m_layer != nullptr && this->m_layer->id() == 0) {
m_avoid_crossing_perimeters.use_external_mp(true);
Expand Down Expand Up @@ -3291,6 +3300,8 @@ LayerResult GCode::process_layer(
bool first_object = true;
for (InstanceToPrint &instance_to_print : instances_to_print) {
const LayerToPrint &layer_to_print = layers[instance_to_print.layer_id];
m_config.apply(instance_to_print.print_object.config(), true);

// To control print speed of the 1st object layer printed over raft interface.
bool object_layer_over_raft = layer_to_print.object_layer && layer_to_print.object_layer->id() > 0 &&
instance_to_print.print_object.slicing_parameters().raft_layers() == layer_to_print.object_layer->id();
Expand All @@ -3310,7 +3321,6 @@ LayerResult GCode::process_layer(
instance_id + "_copy_" +
instance_copy;

m_config.apply(instance_to_print.print_object.config(), true);
m_layer = layer_to_print.layer();
m_object_layer_over_raft = object_layer_over_raft;
m_print_object_instance_id = static_cast<uint16_t>(instance_to_print.instance_id);
Expand Down Expand Up @@ -3545,11 +3555,15 @@ LayerResult GCode::process_layer(
return result;
}

void GCode::apply_print_config(const PrintConfig &print_config)
void GCode::apply_print_configs(const Print&print)
{
m_writer.apply_print_config(print_config);
m_config.apply(print_config);
m_scaled_gcode_resolution = scaled<double>(print_config.gcode_resolution.value);
//apply also default region & object, just in case, as they won't be applied since the first extrusion on a region / the first layer process on an object
m_writer.apply_print_config(print.config());
m_writer.apply_print_region_config(print.default_region_config());
m_config.apply(print.config());
m_config.apply(print.default_object_config());
m_config.apply(print.default_region_config());
m_scaled_gcode_resolution = scale_d(print.config().gcode_resolution.value);
}

void GCode::append_full_config(const Print &print, std::string &str)
Expand Down Expand Up @@ -5880,6 +5894,7 @@ Polyline GCode::travel_to(std::string &gcode, const Point &point, ExtrusionRole
bool could_be_wipe_disabled = false;
// Save state of use_external_mp_once for the case that will be needed to call twice m_avoid_crossing_perimeters.travel_to.
const bool used_external_mp_once = m_avoid_crossing_perimeters.used_external_mp_once();
const bool used_disabled_once = m_avoid_crossing_perimeters.disabled_once();

//can use the avoid crossing algo?
bool can_avoid_cross_peri = m_config.avoid_crossing_perimeters
Expand Down Expand Up @@ -5913,9 +5928,11 @@ Polyline GCode::travel_to(std::string &gcode, const Point &point, ExtrusionRole
//if (could_be_wipe_disabled) {
// m_wipe.reset_path();
//} else {
//check if it cross hull
auto result = diff_pl(Polylines{ travel }, to_polygons(m_layer->lslices));
if (result.empty())
if (result.empty()) {
m_wipe.reset_path();
}
//}
}

Expand All @@ -5935,6 +5952,9 @@ Polyline GCode::travel_to(std::string &gcode, const Point &point, ExtrusionRole
// If in the previous call of m_avoid_crossing_perimeters.travel_to was use_external_mp_once set to true restore this value for next call.
if (used_external_mp_once)
m_avoid_crossing_perimeters.use_external_mp_once();
if (used_disabled_once)
m_avoid_crossing_perimeters.disable_once();

// Because of it, it is necessary to redo the thing
travel = m_avoid_crossing_perimeters.travel_to(*this, point);
updated_first_pos = true;
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/GCode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class GCode : ExtrusionVisitorConst {
// For Perl bindings, to be used exclusively by unit tests.
unsigned int layer_count() const { return m_layer_count; }
void set_layer_count(unsigned int value) { m_layer_count = value; }
void apply_print_config(const PrintConfig &print_config);
void apply_print_configs(const Print &print);

// append full config to the given string
static void append_full_config(const Print& print, std::string& str);
Expand Down
Loading

0 comments on commit dcada9f

Please sign in to comment.