Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::Wipe Class Reference

#include <src/libslic3r/GCode.hpp>

+ Collaboration diagram for Slic3r::Wipe:

Public Member Functions

 Wipe ()
 
bool has_path () const
 
void reset_path ()
 
std::string wipe (GCode &gcodegen, bool toolchange)
 

Public Attributes

bool enable
 
Polyline path
 

Detailed Description

Constructor & Destructor Documentation

◆ Wipe()

Slic3r::Wipe::Wipe ( )
inline
56: enable(false) {}
bool enable
Definition GCode.hpp:53

Member Function Documentation

◆ has_path()

bool Slic3r::Wipe::has_path ( ) const
inline
57{ return ! this->path.empty(); }
bool empty() const
Definition MultiPoint.hpp:40
Polyline path
Definition GCode.hpp:54

References Slic3r::MultiPoint::empty().

Referenced by Slic3r::GCode::retract().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reset_path()

void Slic3r::Wipe::reset_path ( )
inline
58{ this->path.clear(); }
void clear()
Definition MultiPoint.hpp:70

References Slic3r::MultiPoint::clear().

Referenced by Slic3r::WipeTowerIntegration::append_tcr(), Slic3r::GCode::change_layer(), Slic3r::GCode::set_extruder(), Slic3r::GCode::travel_to(), and wipe().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ wipe()

std::string Slic3r::Wipe::wipe ( GCode gcodegen,
bool  toolchange 
)
150 {
151 std::string gcode;
152 const Extruder &extruder = *gcodegen.writer().extruder();
153
154 // Remaining quantized retraction length.
155 if (double retract_length = extruder.retract_to_go(toolchange ? extruder.retract_length_toolchange() : extruder.retract_length());
156 retract_length > 0 && this->path.size() >= 2) {
157 // Reduce feedrate a bit; travel speed is often too high to move on existing material.
158 // Too fast = ripping of existing material; too slow = short wipe path, thus more blob.
159 const double wipe_speed = gcodegen.writer().config.travel_speed.value * 0.8;
160 // Reduce retraction length a bit to avoid effective retraction speed to be greater than the configured one
161 // due to rounding (TODO: test and/or better math for this).
162 const double xy_to_e = 0.95 * extruder.retract_speed() / wipe_speed;
163 // Start with the current position, which may be different from the wipe path start in case of loop clipping.
164 Vec2d prev = gcodegen.point_to_gcode_quantized(gcodegen.last_pos());
165 auto it = this->path.points.begin();
166 Vec2d p = gcodegen.point_to_gcode_quantized(*(++ it));
167 if (p != prev) {
169 auto end = this->path.points.end();
170 bool done = false;
171 for (; it != end && ! done; ++ it) {
172 p = gcodegen.point_to_gcode_quantized(*it);
173 double segment_length = (p - prev).norm();
174 double dE = GCodeFormatter::quantize_e(xy_to_e * segment_length);
175 if (dE > retract_length - EPSILON) {
176 if (dE > retract_length + EPSILON)
177 // Shorten the segment.
178 p = prev + (p - prev) * (retract_length / dE);
179 dE = retract_length;
180 done = true;
181 }
182 //FIXME one shall not generate the unnecessary G1 Fxxx commands, here wipe_speed is a constant inside this cycle.
183 // Is it here for the cooling markers? Or should it be outside of the cycle?
184 gcode += gcodegen.writer().set_speed(wipe_speed * 60, {}, gcodegen.enable_cooling_markers() ? ";_WIPE" : "");
185 gcode += gcodegen.writer().extrude_to_xy(p, -dE, "wipe and retract");
186 prev = p;
187 retract_length -= dE;
188 }
189 // add tag for processor
191 gcodegen.set_last_pos(gcodegen.gcode_to_point(prev));
192 }
193 }
194
195 // Prevent wiping again on the same path.
196 this->reset_path();
197 return gcode;
198 }
static volatile int done
Definition bitbang.c:50
static double quantize_e(double v)
Definition GCodeWriter.hpp:154
static const std::string & reserved_tag(ETags tag)
Definition GCodeProcessor.hpp:186
Points points
Definition MultiPoint.hpp:18
size_t size() const
Definition MultiPoint.hpp:39
void reset_path()
Definition GCode.hpp:58
static constexpr double EPSILON
Definition libslic3r.h:51
Eigen::Matrix< double, 2, 1, Eigen::DontAlign > Vec2d
Definition Point.hpp:51
static coordf_t segment_length(const Polygon &poly, size_t seg1, const Point &p1, size_t seg2, const Point &p2)
Definition FillRectilinear.cpp:44
S::iterator end(S &sh, const PathTag &)
Definition geometry_traits.hpp:620

References Slic3r::GCodeWriter::config, done, Slic3r::GCode::enable_cooling_markers(), EPSILON, Slic3r::GCodeWriter::extrude_to_xy(), Slic3r::GCodeWriter::extruder(), Slic3r::GCode::gcode_to_point(), Slic3r::GCode::last_pos(), path, Slic3r::GCode::point_to_gcode_quantized(), Slic3r::MultiPoint::points, Slic3r::GCodeFormatter::quantize_e(), Slic3r::GCodeProcessor::reserved_tag(), reset_path(), Slic3r::Extruder::retract_length(), Slic3r::Extruder::retract_length_toolchange(), Slic3r::Extruder::retract_speed(), Slic3r::Extruder::retract_to_go(), Slic3r::segment_length(), Slic3r::GCode::set_last_pos(), Slic3r::GCodeWriter::set_speed(), Slic3r::MultiPoint::size(), Slic3r::GCodeProcessor::Wipe_End, Slic3r::GCodeProcessor::Wipe_Start, and Slic3r::GCode::writer().

Referenced by Slic3r::GCode::retract().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ enable

◆ path


The documentation for this class was generated from the following files: