Spiral vase: allow to choose the seam start position.

supermerill/SuperSlicer#2114
This commit is contained in:
supermerill 2022-01-04 22:18:47 +01:00
parent 0c92076a14
commit f0548ab5f7
3 changed files with 14 additions and 4 deletions

View File

@ -3199,8 +3199,9 @@ void GCode::split_at_seam_pos(ExtrusionLoop& loop, std::unique_ptr<EdgeGrid::Gri
// find the point of the loop that is closest to the current extruder position
// or randomize if requested
Point last_pos = this->last_pos();
if (m_config.spiral_vase) {
loop.split_at(last_pos, false);
//for first spiral, choose the seam, as the position will be very relevant.
if (m_config.spiral_vase && !m_spiral_vase->is_transition_layer()) {
loop.split_at(last_pos, false);
} else {
const EdgeGrid::Grid* edge_grid_ptr = (lower_layer_edge_grid && *lower_layer_edge_grid)
? lower_layer_edge_grid->get()

View File

@ -55,9 +55,12 @@ std::string SpiralVase::process_layer(const std::string &gcode)
// Tapering the absolute extruder distances requires to process every extrusion value after the first transition
// layer.
bool transition = m_transition_layer && m_config->use_relative_e_distances.value;
if (transition)
new_gcode += "; Began spiral\n";
bool keep_first_travel = 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]
m_reader.parse_buffer(gcode, [&keep_first_travel , &new_gcode, &z, total_layer_length, layer_height_factor, transition, &len]
(GCodeReader &reader, GCodeReader::GCodeLine line) {
if (line.cmd_is("G1")) {
if (line.has_z()) {
@ -71,12 +74,16 @@ std::string SpiralVase::process_layer(const std::string &gcode)
if (dist_XY > 0) {
// horizontal move
if (line.extruding(reader)) {
keep_first_travel = false;
len += dist_XY;
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';
} else if (keep_first_travel) {
//we can travel until the first spiral extrusion
new_gcode += line.raw() + '\n';
}
return;

View File

@ -19,7 +19,9 @@ public:
m_enabled = en;
}
std::string process_layer(const std::string &gcode);
std::string process_layer(const std::string& gcode);
bool is_transition_layer() { return m_transition_layer; }
private:
const PrintConfig *m_config;