Implemented linear tapering of extrusion rate for the 1st spiral vase layer

above the solid infill. Should fix
first layer of vase (after bottom layers) is bulging (0.6nozzle, 0.4 layerhight) #3712
Adjust flow of the "second" layer in spiral vase mode #2795
This commit is contained in:
Vojtech Bubnik 2020-12-09 14:53:54 +01:00
parent 364300055e
commit 298b730589
3 changed files with 24 additions and 9 deletions

View file

@ -1764,6 +1764,7 @@ void GCode::process_layer(
// Check whether it is possible to apply the spiral vase logic for this layer. // Check whether it is possible to apply the spiral vase logic for this layer.
// Just a reminder: A spiral vase mode is allowed for a single object, single material print only. // Just a reminder: A spiral vase mode is allowed for a single object, single material print only.
m_enable_loop_clipping = true;
if (m_spiral_vase && layers.size() == 1 && support_layer == nullptr) { if (m_spiral_vase && layers.size() == 1 && support_layer == nullptr) {
bool enable = (layer.id() > 0 || print.config().brim_width.value == 0.) && (layer.id() >= (size_t)print.config().skirt_height.value && ! print.has_infinite_skirt()); bool enable = (layer.id() > 0 || print.config().brim_width.value == 0.) && (layer.id() >= (size_t)print.config().skirt_height.value && ! print.has_infinite_skirt());
if (enable) { if (enable) {
@ -1775,10 +1776,10 @@ void GCode::process_layer(
break; break;
} }
} }
m_spiral_vase->enable = enable; m_spiral_vase->enable(enable);
// If we're going to apply spiralvase to this layer, disable loop clipping.
m_enable_loop_clipping = !enable;
} }
// If we're going to apply spiralvase to this layer, disable loop clipping
m_enable_loop_clipping = ! m_spiral_vase || ! m_spiral_vase->enable;
std::string gcode; std::string gcode;

View file

@ -16,7 +16,7 @@ std::string SpiralVase::process_layer(const std::string &gcode)
// If we're not going to modify G-code, just feed it to the reader // If we're not going to modify G-code, just feed it to the reader
// in order to update positions. // in order to update positions.
if (! this->enable) { if (! m_enabled) {
m_reader.parse_buffer(gcode); m_reader.parse_buffer(gcode);
return gcode; return gcode;
} }
@ -50,7 +50,10 @@ std::string SpiralVase::process_layer(const std::string &gcode)
z -= layer_height; z -= layer_height;
std::string new_gcode; std::string new_gcode;
m_reader.parse_buffer(gcode, [&new_gcode, &z, &layer_height, &total_layer_length] bool transition = m_transition_layer;
float layer_height_factor = layer_height / total_layer_length;
float len = 0.f;
m_reader.parse_buffer(gcode, [&new_gcode, &z, total_layer_length, layer_height_factor, transition, &len]
(GCodeReader &reader, GCodeReader::GCodeLine line) { (GCodeReader &reader, GCodeReader::GCodeLine line) {
if (line.cmd_is("G1")) { if (line.cmd_is("G1")) {
if (line.has_z()) { if (line.has_z()) {
@ -64,8 +67,11 @@ std::string SpiralVase::process_layer(const std::string &gcode)
if (dist_XY > 0) { if (dist_XY > 0) {
// horizontal move // horizontal move
if (line.extruding(reader)) { if (line.extruding(reader)) {
z += dist_XY * layer_height / total_layer_length; len += dist_XY;
line.set(reader, Z, z); line.set(reader, Z, z + len * layer_height_factor);
if (transition && line.has(E))
// Transition layer, modulate the amount of extrusion from zero to the final value.
line.set(reader, E, line.value(E) * len / total_layer_length);
new_gcode += line.raw() + '\n'; new_gcode += line.raw() + '\n';
} }
return; return;

View file

@ -8,18 +8,26 @@ namespace Slic3r {
class SpiralVase { class SpiralVase {
public: public:
bool enable = false;
SpiralVase(const PrintConfig &config) : m_config(&config) SpiralVase(const PrintConfig &config) : m_config(&config)
{ {
m_reader.z() = (float)m_config->z_offset; m_reader.z() = (float)m_config->z_offset;
m_reader.apply_config(*m_config); m_reader.apply_config(*m_config);
}; };
void enable(bool en) {
m_transition_layer = en && ! m_enabled;
m_enabled = en;
}
std::string process_layer(const std::string &gcode); std::string process_layer(const std::string &gcode);
private: private:
const PrintConfig *m_config; const PrintConfig *m_config;
GCodeReader m_reader; GCodeReader m_reader;
bool m_enabled = false;
// First spiral vase layer. Layer height has to be ramped up from zero to the target layer height.
bool m_transition_layer = false;
}; };
} }