Skip to content

Commit

Permalink
new wipe settings: wipe_min, wipe_lift_min
Browse files Browse the repository at this point in the history
 * allow to ensure the wipe is long enough
 * the wipe lift can start after the start
  • Loading branch information
supermerill committed Oct 26, 2024
1 parent 48dd9c8 commit 3928846
Show file tree
Hide file tree
Showing 12 changed files with 396 additions and 111 deletions.
6 changes: 5 additions & 1 deletion resources/ui_layout/default/extruder.ui
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ group:General wipe
setting:idx:label$Depth:wipe_inside_depth
end_line
setting:idx:wipe_extra_perimeter
setting:idx:wipe_lift
line:Wipe lift
setting:idx:label$height:wipe_lift
setting:idx:label$length:wipe_lift_length
end_line
setting:idx:wipe_min
line:Seam gap
setting:idx:label$_:sidetext_width$5:seam_gap
setting:idx:label$for external perimeters:sidetext_width$5:seam_gap_external
Expand Down
48 changes: 27 additions & 21 deletions src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ using namespace std::literals::string_view_literals;
#endif

#include <assert.h>
#pragma UNOPTIMIZE

namespace Slic3r {

// Only add a newline in case the current G-code does not end with a newline.
Expand Down Expand Up @@ -3351,7 +3351,7 @@ LayerResult GCodeGenerator::process_layer(
const ExtrusionEntityCollection& coll = first_layer && print.skirt_first_layer() ? *print.skirt_first_layer() : print.skirt();
for (size_t i = loops.first; i < loops.second; ++i) {
m_region = nullptr;
set_region_for_extrude(print, nullptr, gcode);
set_region_for_extrude(print, nullptr, nullptr, gcode);
// Adjust flow according to this layer's layer height.
this->extrude_skirt(dynamic_cast<ExtrusionLoop&>(*coll.entities()[i]),
// Override of skirt extrusion parameters. extrude_skirt() will fill in the extrusion width.
Expand All @@ -3373,7 +3373,7 @@ LayerResult GCodeGenerator::process_layer(
this->set_origin(0., 0.);
m_avoid_crossing_perimeters.use_external_mp();
m_region = nullptr;
set_region_for_extrude(print, nullptr, gcode);
set_region_for_extrude(print, nullptr, nullptr, gcode);
for (const ExtrusionEntity* brim_entity : print.brim().entities()) {
//if first layer, ask for a bigger lift for travel to each brim, to be on the safe side
set_extra_lift(m_last_layer_z, layer.id(), print.config(), m_writer, extruder_id);
Expand All @@ -3396,7 +3396,7 @@ LayerResult GCodeGenerator::process_layer(
const PrintObject *print_object = layers.front().object();
//object skirt & brim use the object settings.
m_region = nullptr;
set_region_for_extrude(print, print_object, gcode);
set_region_for_extrude(print, print_object, nullptr, gcode);
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() )) {
//TODO: check if I don't need to call extrude_skirt to have arcs.
Expand All @@ -3416,7 +3416,7 @@ LayerResult GCodeGenerator::process_layer(
const PrintObject* print_object = layers.front().object();
//object skirt & brim use the object settings.
m_region = nullptr;
set_region_for_extrude(print, print_object, gcode);
set_region_for_extrude(print, print_object, nullptr, gcode);
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 @@ -4799,7 +4799,7 @@ std::string GCodeGenerator::extrude_loop(const ExtrusionLoop &original_loop, con
m_writer.set_acceleration((uint16_t)floor(get_default_acceleration(m_config) + 0.5));

//basic wipe, may be erased after if we need a more complex one
add_wipe_points(wipe_paths);
add_wipe_points(wipe_paths, false, true);

//wipe for External Perimeter (and not vase)
//TODO: move that into a wipe object's new method. (like wipe_hide_seam did for PS)
Expand Down Expand Up @@ -4866,7 +4866,7 @@ std::string GCodeGenerator::extrude_loop(const ExtrusionLoop &original_loop, con
wipe_polyline.append(path.polyline);
}
}
m_wipe.set_path(wipe_polyline.get_arc());
m_wipe.set_path(wipe_polyline.get_arc(), true);
//move
for (ExtrusionPath& path : paths_wipe) {
Point center;
Expand Down Expand Up @@ -5124,7 +5124,7 @@ std::string GCodeGenerator::extrude_loop(const ExtrusionLoop &original_loop, con
wipe_path.append(poly.points[pt_idx]);
}
for (size_t pt_idx = 0; pt_idx < best_pt_idx; pt_idx++) { wipe_path.append(poly.points[pt_idx]); }
m_wipe.set_path(std::move(wipe_path.get_arc()));
m_wipe.set_path(std::move(wipe_path.get_arc()), true);
}

if (!start_wipe.empty()) {
Expand All @@ -5150,7 +5150,7 @@ std::string GCodeGenerator::extrude_loop(const ExtrusionLoop &original_loop, con
}

template <typename THING>
void GCodeGenerator::add_wipe_points(const std::vector<THING>& paths, bool reverse /*= true*/) {
void GCodeGenerator::add_wipe_points(const std::vector<THING>& paths, bool reverse, bool is_loop) {
if (m_wipe.is_enabled()) {
ArcPolyline wipe_polyline;
for (const THING& path : paths) {
Expand All @@ -5166,7 +5166,7 @@ void GCodeGenerator::add_wipe_points(const std::vector<THING>& paths, bool rever
if (reverse) {
wipe_polyline.reverse();
}
m_wipe.set_path(wipe_polyline.get_arc());
m_wipe.set_path(wipe_polyline.get_arc(), is_loop);
}
}

Expand Down Expand Up @@ -5205,14 +5205,14 @@ std::string GCodeGenerator::extrude_multi_path(const ExtrusionMultiPath &multipa
gcode += extrude_path(path, description, speed);
}
}
add_wipe_points(multipath.paths, false);
add_wipe_points(multipath.paths, false, false);
} else {
this->visitor_flipped = false;
// extrude along the path
for (const ExtrusionPath& path : multipath.paths) {
gcode += extrude_path(path, description, speed);
}
add_wipe_points(multipath.paths, true);
add_wipe_points(multipath.paths, true, false);
};
this->visitor_flipped = saved_flipped;
// reset acceleration
Expand Down Expand Up @@ -5264,14 +5264,14 @@ std::string GCodeGenerator::extrude_multi_path3D(const ExtrusionMultiPath3D &mul
// extrude_path will reverse the path by itself, no need to copy it do to it here.
gcode += extrude_path_3D(multipath3D.paths[idx_path], description, speed);
}
add_wipe_points(multipath3D.paths, false);
add_wipe_points(multipath3D.paths, false, false);
} else {
this->visitor_flipped = false;
for (const ExtrusionPath3D &path : multipath3D.paths) {
gcode += extrude_path_3D(path, description, speed);
//extrudepath3D(path);
}
add_wipe_points(multipath3D.paths, true);
add_wipe_points(multipath3D.paths, true, false);
}
this->visitor_flipped = saved_flipped;
// reset acceleration
Expand Down Expand Up @@ -5380,7 +5380,7 @@ std::string GCodeGenerator::extrude_path(const ExtrusionPath &path, const std::s
//simplifed_path will be discarded i can reuse it to create the wipe
if (m_wipe.is_enabled()) {
simplifed_path.reverse();
m_wipe.set_path(simplifed_path.polyline.get_arc());
m_wipe.set_path(simplifed_path.polyline.get_arc(), false);
}
// reset acceleration
m_writer.set_acceleration((uint16_t)floor(get_default_acceleration(m_config) + 0.5));
Expand Down Expand Up @@ -5425,14 +5425,14 @@ std::string GCodeGenerator::extrude_path_3D(const ExtrusionPath3D &path, const s
if (m_wipe.is_enabled()) {
ArcPolyline temp = simplifed_path.as_polyline();
temp.reverse();
m_wipe.set_path(std::move(temp.get_arc()));
m_wipe.set_path(std::move(temp.get_arc()), false);
}
// reset acceleration
m_writer.set_acceleration((uint16_t)floor(get_default_acceleration(m_config) + 0.5));
return gcode;
}

void GCodeGenerator::set_region_for_extrude(const Print &print, const PrintObject *print_object, std::string &gcode)
void GCodeGenerator::set_region_for_extrude(const Print &print, const PrintObject *print_object, const LayerRegion *layerm, std::string &gcode)
{
const PrintRegionConfig &region_config = this->m_region == nullptr ?
//FIXME
Expand Down Expand Up @@ -5467,6 +5467,12 @@ void GCodeGenerator::set_region_for_extrude(const Print &print, const PrintObjec
m_writer.tool()->id(), &config) +
"\n";
}
// give the boundary to wipe
if (layerm) {
m_wipe.set_boundaries(&layerm->get_cached_slices());
} else {
m_wipe.set_boundaries(nullptr);
}
}

// Extrude perimeters: Decide where to put seams (hide or align seams).
Expand Down Expand Up @@ -5503,7 +5509,7 @@ void GCodeGenerator::extrude_perimeters(const ExtrudeArgs &print_args, const Lay
if (first) {
first = false;
// Apply region-specific settings
set_region_for_extrude(print, nullptr, gcode);
set_region_for_extrude(print, nullptr, &layerm, gcode);
}
to_extrude.push_back(eec);
}
Expand Down Expand Up @@ -5554,7 +5560,7 @@ void GCodeGenerator::extrude_infill(const ExtrudeArgs& print_args, const LayerIs
}
}
if (!temp_fill_extrusions.empty()) {
set_region_for_extrude(print, nullptr, gcode);
set_region_for_extrude(print, nullptr, &layerm, gcode);
for (const ExtrusionEntityReference &fill :
chain_extrusion_references(temp_fill_extrusions, last_pos_defined() ? &last_pos() : nullptr)) {
gcode += this->extrude_entity(fill, "infill"sv);
Expand Down Expand Up @@ -5594,7 +5600,7 @@ void GCodeGenerator::extrude_ironing(const ExtrudeArgs &print_args, const LayerI
}
}
if (!temp_fill_extrusions.empty()) {
set_region_for_extrude(print, nullptr, gcode);
set_region_for_extrude(print, nullptr, &layerm, gcode);
for (const ExtrusionEntityReference &fill : chain_extrusion_references(temp_fill_extrusions, last_pos_defined() ? &last_pos() : nullptr))
gcode += this->extrude_entity(fill, "ironing"sv);
}
Expand Down Expand Up @@ -5624,7 +5630,7 @@ void GCodeGenerator::extrude_skirt(

if (m_wipe.is_enabled())
// Wipe will hide the seam.
m_wipe.set_path(loop_src.paths, false);
m_wipe.set_path(loop_src.paths, false, true);

}

Expand Down
4 changes: 2 additions & 2 deletions src/libslic3r/GCode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ class GCodeGenerator : ExtrusionVisitorConst {

void split_at_seam_pos(ExtrusionLoop &loop, bool was_clockwise);
template <typename THING = ExtrusionEntity> // can be templated safely because private
void add_wipe_points(const std::vector<THING>& paths, bool reverse = true);
void add_wipe_points(const std::vector<THING>& paths, bool reverse, bool is_loop);
void seam_notch(const ExtrusionLoop& original_loop, ExtrusionPaths& building_paths,
ExtrusionPaths& notch_extrusion_start, ExtrusionPaths& notch_extrusion_end, bool is_hole_loop, bool is_full_loop_ccw);

Expand Down Expand Up @@ -357,7 +357,7 @@ class GCodeGenerator : ExtrusionVisitorConst {
// set the region config, and the overrides it contains.
// if no m_region, then it will take the default region config from print_object
// if no print_object, then it will take the default region config from print
void set_region_for_extrude(const Print &print, const PrintObject *print_object, std::string &gcode);
void set_region_for_extrude(const Print &print, const PrintObject *print_object, const LayerRegion *layerm, std::string &gcode);
void extrude_perimeters(const ExtrudeArgs &print_args, const LayerIsland &island, std::string &gcode);
void extrude_infill(const ExtrudeArgs &print_args, const LayerIsland &island, bool is_infill_first, std::string &gcode);
void extrude_ironing(const ExtrudeArgs &print_args, const LayerIsland &island, std::string &gcode);
Expand Down
Loading

0 comments on commit 3928846

Please sign in to comment.