OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::Wipe Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/GCode.hpp>

Collaboration diagram for Slic3r::Wipe:

Classes

struct  RetractionValues

Public Member Functions

 Wipe ()
bool has_path () const
void reset_path ()
std::string wipe (GCode &gcodegen, double length, bool toolchange=false, bool is_last=false)
RetractionValues calculateWipeRetractionLengths (GCode &gcodegen, bool toolchange)
void update_path (const ExtrusionPaths &paths, bool reverse=false)

Public Attributes

bool enable
Polyline path

Detailed Description


Class Documentation

◆ Slic3r::Wipe::RetractionValues

struct Slic3r::Wipe::RetractionValues
Class Members
double retraction_length_after_wipe = 0.
double retraction_length_before_wipe = 0.
double retraction_length_during_wipe = 0.

Constructor & Destructor Documentation

◆ Wipe()

Slic3r::Wipe::Wipe ( )
inline
92: enable(false) {}
bool enable
Definition GCode.hpp:82

References enable.

Member Function Documentation

◆ calculateWipeRetractionLengths()

Wipe::RetractionValues Slic3r::Wipe::calculateWipeRetractionLengths ( GCode & gcodegen,
bool toolchange )
538 {
539 auto& writer = gcodegen.writer();
540 auto& config = gcodegen.config();
541 auto extruder = writer.filament();
542 auto last_pos = gcodegen.last_pos();
543
544 // Declare & initialize retraction lengths
545 double retraction_length_remaining = 0,
546 retraction_length_before_wipe = 0,
547 retraction_length_during_wipe = 0,
548 retraction_length_after_wipe = 0;
549
550 // Initialise the remaining retraction amount with the full retraction amount.
551 retraction_length_remaining = toolchange ?
552 extruder->retract_length_toolchange() : extruder->retraction_length();
553
554 // Nothing to retract - return early
555 if (retraction_length_remaining <= EPSILON)
556 return { 0.f, 0.f, 0.f };
557
558 // Calculate retraction before and after wipe distances from the user setting.
559 // Keep adding to the for retraction before wipe variable any excess retraction
560 // needed to be performed before the wipe.
561 retraction_length_before_wipe = retraction_length_remaining * extruder->retract_before_wipe();
562 retraction_length_after_wipe = retraction_length_remaining * extruder->retract_after_wipe();
563
564 // Subtract it from the remaining retraction length
565 retraction_length_remaining -= retraction_length_before_wipe + retraction_length_after_wipe;
566
567 // All of the retraction is to be done before the wipe
568 if (retraction_length_remaining <= EPSILON)
569 return { retraction_length_before_wipe, 0., retraction_length_after_wipe };
570
571 // Calculate wipe speed
572 // Orca: resolve the travel_speed slot via the Print-side per-layer resolver; the writer's
573 // per-layer synced config would yield the same index.
574 double wipe_speed = config.role_based_wipe_speed ? writer.get_current_speed() / 60.0 : config.get_abs_value("wipe_speed", gcodegen.config().travel_speed.get_at(gcodegen.get_nozzle_config_index(gcodegen.writer().filament()->id())));
575 wipe_speed = std::max(wipe_speed, 10.0);
576
577 // Process wipe path & calculate wipe path length
578 double wipe_dist = scale_(config.wipe_distance.get_at(extruder->config_index()));
579 Polyline wipe_path = {last_pos};
580 wipe_path.append(this->path.points.begin() + 1, this->path.points.end());
581 double wipe_path_length = std::min(wipe_path.length(), wipe_dist);
582
583 // Calculate the maximum retraction amount during wipe
584 retraction_length_during_wipe = config.retraction_speed.get_at(extruder->config_index()) *
585 unscale_(wipe_path_length) / wipe_speed;
586
587 // If the maximum retraction amount during wipe is too small,
588 // disable wipe-time retraction and leave any remaining retract amount
589 // to the subsequent standard retract flow.
590 if (retraction_length_during_wipe <= EPSILON)
591 return { retraction_length_before_wipe, 0., retraction_length_after_wipe };
592
593 // If the maximum retraction amount during wipe is greater than any remaining retraction length
594 // return the remaining retraction length to be retracted during the wipe
595 if (retraction_length_during_wipe - retraction_length_remaining > EPSILON)
596 return { retraction_length_before_wipe, retraction_length_remaining, retraction_length_after_wipe };
597
598 // We will always proceed with incrementing the retraction amount before wiping with the difference
599 // and return the maximum allowed wipe amount to be retracted during the wipe move
600 retraction_length_before_wipe += retraction_length_remaining - retraction_length_during_wipe;
601
602 return { retraction_length_before_wipe, retraction_length_during_wipe, retraction_length_after_wipe };
603 }
#define EPSILON
Definition ColorUtils.cpp:64
Polyline path
Definition GCode.hpp:83
#define unscale_(val)
Definition libslic3r.h:107
#define scale_(val)
Definition libslic3r.h:106

References Slic3r::Polyline::append(), Slic3r::GCode::config(), EPSILON, Slic3r::GCodeWriter::filament(), Slic3r::GCode::get_nozzle_config_index(), Slic3r::Extruder::id(), Slic3r::GCode::last_pos(), Slic3r::MultiPoint::length(), path, scale_, unscale_, and Slic3r::GCode::writer().

Here is the call graph for this function:

◆ has_path()

bool Slic3r::Wipe::has_path ( ) const
inline
93{ return !this->path.points.empty(); }

References Slic3r::MultiPoint::points.

◆ reset_path()

void Slic3r::Wipe::reset_path ( )
inline
94{ this->path = Polyline(); }

Referenced by Slic3r::WipeTowerIntegration::append_tcr(), Slic3r::WipeTowerIntegration::append_tcr2(), update_path(), and wipe().

Here is the caller graph for this function:

◆ update_path()

void Slic3r::Wipe::update_path ( const ExtrusionPaths & paths,
bool reverse = false )
669 {
670 reset_path();
671 for (const ExtrusionPath& extrusion_path : paths)
672 path.append(extrusion_path.polyline.to_polyline());
673 if (reverse)
674 path.reverse();
675 }
void reset_path()
Definition GCode.hpp:94

References path, and reset_path().

Here is the call graph for this function:

◆ wipe()

std::string Slic3r::Wipe::wipe ( GCode & gcodegen,
double length,
bool toolchange = false,
bool is_last = false )
678 {
679 std::string gcode;
680
681 /* Reduce feedrate a bit; travel speed is often too high to move on existing material.
682 Too fast = ripping of existing material; too slow = short wipe path, thus more blob. */
683 // Orca: resolve the travel_speed slot via the Print-side per-layer resolver; the writer's
684 // per-layer synced config would yield the same index.
685 double _wipe_speed = gcodegen.config().get_abs_value("wipe_speed", gcodegen.config().travel_speed.get_at(gcodegen.get_nozzle_config_index(gcodegen.writer().filament()->id())));// gcodegen.writer().config.travel_speed.value * 0.8;
686 if(gcodegen.config().role_based_wipe_speed)
687 _wipe_speed = gcodegen.writer().get_current_speed() / 60.0;
688 if(_wipe_speed < 10)
689 _wipe_speed = 10;
690
691
692 //SoftFever: allow 100% retract before wipe
693 if (length >= 0)
694 {
695 /* Calculate how long we need to travel in order to consume the required
696 amount of retraction. In other words, how far do we move in XY at wipe_speed
697 for the time needed to consume retraction_length at retraction_speed? */
698 // BBS
699 double wipe_dist = scale_(gcodegen.config().wipe_distance.get_at(gcodegen.get_filament_config_index((int)gcodegen.writer().filament()->id())));
700
701 /* Take the stored wipe path and replace first point with the current actual position
702 (they might be different, for example, in case of loop clipping). */
703 Polyline wipe_path;
704 wipe_path.append(gcodegen.last_pos());
705 wipe_path.append(
706 this->path.points.begin() + 1,
707 this->path.points.end()
708 );
709
710 wipe_path.clip_end(wipe_path.length() - wipe_dist);
711
712 // subdivide the retraction in segments
713 if (!wipe_path.empty()) {
714 // BBS. Handle short path case.
715 if (wipe_path.length() < wipe_dist) {
716 wipe_dist = wipe_path.length();
717 //BBS: avoid to divide 0
718 wipe_dist = wipe_dist < EPSILON ? EPSILON : wipe_dist;
719 }
720
721 // add tag for processor
723 //BBS: don't need to enable cooling makers when this is the last wipe. Because no more cooling layer will clean this "_WIPE"
724 //Softfever:
725 std::string cooling_mark = "";
726 if (gcodegen.enable_cooling_markers() && !is_last)
727 cooling_mark = /*gcodegen.config().role_based_wipe_speed ? ";_EXTERNAL_PERIMETER" : */";_WIPE";
728
729 // Orca: set speed once because wipe_speed is constant for all segments.
730 gcode += gcodegen.writer().set_speed(_wipe_speed * 60, "", cooling_mark);
731 for (const Line& line : wipe_path.lines()) {
732 double segment_length = line.length();
733 double dE = length * (segment_length / wipe_dist);
734 gcode += gcodegen.writer().extrude_to_xy(
735 gcodegen.point_to_gcode(line.b),
736 -dE,
737 "wipe and retract"
738 );
739 }
740 // add tag for processor
742 gcodegen.set_last_pos(wipe_path.points.back());
743 }
744
745 // prevent wiping again on same path
746 this->reset_path();
747 }
748
749 return gcode;
750 }
static const std::string & reserved_tag(ETags tag)
Definition GCodeProcessor.hpp:636
@ Wipe_End
Definition GCodeProcessor.hpp:606
@ Wipe_Start
Definition GCodeProcessor.hpp:605
@ gcode
Definition Time.hpp:14
double length(const Points &pts)
Definition MultiPoint.hpp:181
static coordf_t segment_length(const Polygon &poly, size_t seg1, const Point &p1, size_t seg2, const Point &p2)
Definition FillRectilinear.cpp:64

References Slic3r::Polyline::append(), Slic3r::Polyline::clip_end(), Slic3r::GCode::config(), Slic3r::MultiPoint::empty(), Slic3r::GCode::enable_cooling_markers(), EPSILON, Slic3r::GCodeWriter::extrude_to_xy(), Slic3r::GCodeWriter::filament(), Slic3r::GCodeWriter::get_current_speed(), Slic3r::GCode::get_filament_config_index(), Slic3r::GCode::get_nozzle_config_index(), Slic3r::Extruder::id(), Slic3r::GCode::last_pos(), Slic3r::length(), Slic3r::MultiPoint::length(), Slic3r::Polyline::lines(), path, Slic3r::GCode::point_to_gcode(), Slic3r::MultiPoint::points, Slic3r::GCodeProcessor::reserved_tag(), reset_path(), scale_, Slic3r::segment_length(), Slic3r::GCode::set_last_pos(), Slic3r::GCodeWriter::set_speed(), Slic3r::GCodeProcessor::Wipe_End, Slic3r::GCodeProcessor::Wipe_Start, and Slic3r::GCode::writer().

Here is the call graph for this function:

Member Data Documentation

◆ enable

bool Slic3r::Wipe::enable

Referenced by Wipe().

◆ path


The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/GCode.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/GCode.cpp