Multimaterial purging lines fixed on rectangular beds with non-standard origin (#3805)

This commit is contained in:
Lukas Matena 2020-03-10 15:27:27 +01:00
parent 27595de1aa
commit a48a79603c
3 changed files with 10 additions and 7 deletions

View file

@ -291,7 +291,7 @@ std::string WipeTowerIntegration::append_tcr(GCode &gcodegen, const WipeTower::T
std::string gcode; std::string gcode;
// Toolchangeresult.gcode assumes the wipe tower corner is at the origin // Toolchangeresult.gcode assumes the wipe tower corner is at the origin (except for priming lines)
// We want to rotate and shift all extrusions (gcode postprocessing) and starting and ending position // We want to rotate and shift all extrusions (gcode postprocessing) and starting and ending position
float alpha = m_wipe_tower_rotation/180.f * float(M_PI); float alpha = m_wipe_tower_rotation/180.f * float(M_PI);
Vec2f start_pos = tcr.start_pos; Vec2f start_pos = tcr.start_pos;
@ -431,7 +431,6 @@ std::string WipeTowerIntegration::post_process_wipe_tower_moves(const WipeTower:
Vec2f pos = tcr.start_pos; Vec2f pos = tcr.start_pos;
Vec2f transformed_pos = pos; Vec2f transformed_pos = pos;
Vec2f old_pos(-1000.1f, -1000.1f); Vec2f old_pos(-1000.1f, -1000.1f);
std::string never_skip_tag = WipeTower::never_skip_tag();
while (gcode_str) { while (gcode_str) {
std::getline(gcode_str, line); // we read the gcode line by line std::getline(gcode_str, line); // we read the gcode line by line
@ -441,11 +440,11 @@ std::string WipeTowerIntegration::post_process_wipe_tower_moves(const WipeTower:
// WT generator can override this by appending the never_skip_tag // WT generator can override this by appending the never_skip_tag
if (line.find("G1 ") == 0) { if (line.find("G1 ") == 0) {
bool never_skip = false; bool never_skip = false;
auto it = line.find(never_skip_tag); auto it = line.find(WipeTower::never_skip_tag());
if (it != std::string::npos) { if (it != std::string::npos) {
// remove the tag and remember we saw it // remove the tag and remember we saw it
never_skip = true; never_skip = true;
line.erase(it, it+never_skip_tag.size()); line.erase(it, it+WipeTower::never_skip_tag().size());
} }
std::ostringstream line_out; std::ostringstream line_out;
std::istringstream line_str(line); std::istringstream line_str(line);

View file

@ -492,6 +492,9 @@ WipeTower::WipeTower(const PrintConfig& config, const std::vector<std::vector<fl
const std::vector<Vec2d>& bed_points = config.bed_shape.values; const std::vector<Vec2d>& bed_points = config.bed_shape.values;
m_bed_shape = (bed_points.size() == 4 ? RectangularBed : CircularBed); m_bed_shape = (bed_points.size() == 4 ? RectangularBed : CircularBed);
m_bed_width = float(BoundingBoxf(bed_points).size().x()); m_bed_width = float(BoundingBoxf(bed_points).size().x());
m_bed_bottom_left = m_bed_shape == RectangularBed
? Vec2f(bed_points.front().x(), bed_points.front().y())
: Vec2f::Zero();
} }
@ -566,6 +569,8 @@ std::vector<WipeTower::ToolChangeResult> WipeTower::prime(
// In case of a circular bed, place it so it goes across the diameter and hope it will fit // In case of a circular bed, place it so it goes across the diameter and hope it will fit
if (m_bed_shape == CircularBed) if (m_bed_shape == CircularBed)
cleaning_box.translate(-m_bed_width/2 + m_bed_width * 0.03f, -m_bed_width * 0.12f); cleaning_box.translate(-m_bed_width/2 + m_bed_width * 0.03f, -m_bed_width * 0.12f);
if (m_bed_shape == RectangularBed)
cleaning_box.translate(m_bed_bottom_left);
std::vector<ToolChangeResult> results; std::vector<ToolChangeResult> results;

View file

@ -21,7 +21,7 @@ enum GCodeFlavor : unsigned char;
class WipeTower class WipeTower
{ {
public: public:
static char const* never_skip_tag() { return "_GCODE_WIPE_TOWER_NEVER_SKIP_TAG"; } static const std::string never_skip_tag() { return "_GCODE_WIPE_TOWER_NEVER_SKIP_TAG"; }
struct Extrusion struct Extrusion
{ {
@ -189,8 +189,6 @@ public:
}; };
private: private:
WipeTower();
enum wipe_shape // A fill-in direction enum wipe_shape // A fill-in direction
{ {
SHAPE_NORMAL = 1, SHAPE_NORMAL = 1,
@ -236,6 +234,7 @@ private:
CircularBed CircularBed
} m_bed_shape; } m_bed_shape;
float m_bed_width; // width of the bed bounding box float m_bed_width; // width of the bed bounding box
Vec2f m_bed_bottom_left; // bottom-left corner coordinates (for rectangular beds)
float m_perimeter_width = 0.4f * Width_To_Nozzle_Ratio; // Width of an extrusion line, also a perimeter spacing for 100% infill. float m_perimeter_width = 0.4f * Width_To_Nozzle_Ratio; // Width of an extrusion line, also a perimeter spacing for 100% infill.
float m_extrusion_flow = 0.038f; //0.029f;// Extrusion flow is derived from m_perimeter_width, layer height and filament diameter. float m_extrusion_flow = 0.038f; //0.029f;// Extrusion flow is derived from m_perimeter_width, layer height and filament diameter.