fix some seam_gap issues:

* fix scale
 * continue traveling up to the old gap position (or continue with wipe_extra_perimeter)
supermerill/SuperSlicer#57
This commit is contained in:
supermerill 2021-12-11 19:34:58 +01:00
parent b2669f711f
commit 4f5e801ecf
3 changed files with 41 additions and 16 deletions

View File

@ -213,21 +213,25 @@ void ExtrusionLoop::split_at(const Point &point, bool prefer_non_overhang)
this->split_at_vertex(p); this->split_at_vertex(p);
} }
void ExtrusionLoop::clip_end(double distance, ExtrusionPaths* paths) const ExtrusionPaths clip_end(ExtrusionPaths& paths, double distance)
{ {
*paths = this->paths; ExtrusionPaths removed;
while (distance > 0 && !paths->empty()) { while (distance > 0 && !paths.empty()) {
ExtrusionPath &last = paths->back(); ExtrusionPath& last = paths.back();
removed.push_back(last);
double len = last.length(); double len = last.length();
if (len <= distance) { if (len <= distance) {
paths->pop_back(); paths.pop_back();
distance -= len; distance -= len;
} else { } else {
last.polyline.clip_end(distance); last.polyline.clip_end(distance);
removed.back().polyline.clip_start(removed.back().polyline.length() - distance);
break; break;
} }
} }
std::reverse(removed.begin(), removed.end());
return removed;
} }
bool ExtrusionLoop::has_overhang_point(const Point &point) const bool ExtrusionLoop::has_overhang_point(const Point &point) const

View File

@ -279,6 +279,7 @@ protected:
ExtrusionRole m_role; ExtrusionRole m_role;
}; };
typedef std::vector<ExtrusionPath> ExtrusionPaths; typedef std::vector<ExtrusionPath> ExtrusionPaths;
ExtrusionPaths clip_end(ExtrusionPaths& paths, double distance);
class ExtrusionPath3D : public ExtrusionPath { class ExtrusionPath3D : public ExtrusionPath {
public: public:
@ -451,7 +452,6 @@ public:
double length() const override; double length() const override;
bool split_at_vertex(const Point &point); bool split_at_vertex(const Point &point);
void split_at(const Point &point, bool prefer_non_overhang); void split_at(const Point &point, bool prefer_non_overhang);
void clip_end(double distance, ExtrusionPaths* paths) const;
// Test, whether the point is extruded by a bridging flow. // Test, whether the point is extruded by a bridging flow.
// This used to be used to avoid placing seams on overhangs, but now the EdgeGrid is used instead. // This used to be used to avoid placing seams on overhangs, but now the EdgeGrid is used instead.
bool has_overhang_point(const Point &point) const; bool has_overhang_point(const Point &point) const;

View File

@ -2949,13 +2949,23 @@ std::string GCode::extrude_loop_vase(const ExtrusionLoop &original_loop, const s
// clip the path to avoid the extruder to get exactly on the first point of the loop; // clip the path to avoid the extruder to get exactly on the first point of the loop;
// if polyline was shorter than the clipping distance we'd get a null polyline, so // if polyline was shorter than the clipping distance we'd get a null polyline, so
// we discard it in that case // we discard it in that case
double clip_length = 0; coordf_t clip_length = 0;
coordf_t min_clip_length = scale_(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, 0)) * 0.15;
if (m_enable_loop_clipping && m_writer.tool_is_extruder()) if (m_enable_loop_clipping && m_writer.tool_is_extruder())
clip_length = m_config.seam_gap.get_abs_value(m_writer.tool()->id(), scale_(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, 0))); clip_length = scale_(m_config.seam_gap.get_abs_value(m_writer.tool()->id(), EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, 0)));
// get paths // get paths
ExtrusionPaths paths; ExtrusionPaths paths = loop.paths;
loop.clip_end(clip_length, &paths); ExtrusionPaths clipped;
if (clip_length > min_clip_length) {
clipped = clip_end(paths, clip_length);
clip_end(clipped, min_clip_length);
for (ExtrusionPath& ep : clipped)
ep.mm3_per_mm = 0;
append(paths, clipped);
} else {
clip_end(paths, clip_length);
}
if (paths.empty()) return ""; if (paths.empty()) return "";
// apply the small/external? perimeter speed // apply the small/external? perimeter speed
@ -3063,7 +3073,9 @@ std::string GCode::extrude_loop_vase(const ExtrusionLoop &original_loop, const s
double e_per_mm_per_height = (path->mm3_per_mm / this->m_layer->height) double e_per_mm_per_height = (path->mm3_per_mm / this->m_layer->height)
* m_writer.tool()->e_per_mm3() * m_writer.tool()->e_per_mm3()
* this->config().print_extrusion_multiplier.get_abs_value(1); * this->config().print_extrusion_multiplier.get_abs_value(1);
if (m_writer.extrusion_axis().empty()) e_per_mm_per_height = 0; if (m_writer.extrusion_axis().empty())
e_per_mm_per_height = 0;
//extrude
{ {
std::string comment = m_config.gcode_comments ? description : ""; std::string comment = m_config.gcode_comments ? description : "";
for (const Line &line : path->polyline.lines()) { for (const Line &line : path->polyline.lines()) {
@ -3271,13 +3283,23 @@ std::string GCode::extrude_loop(const ExtrusionLoop &original_loop, const std::s
// clip the path to avoid the extruder to get exactly on the first point of the loop; // clip the path to avoid the extruder to get exactly on the first point of the loop;
// if polyline was shorter than the clipping distance we'd get a null polyline, so // if polyline was shorter than the clipping distance we'd get a null polyline, so
// we discard it in that case // we discard it in that case
double clip_length = 0; coordf_t clip_length = 0;
coordf_t min_clip_length = scale_(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, 0)) * 0.15;
if (m_enable_loop_clipping && m_writer.tool_is_extruder()) if (m_enable_loop_clipping && m_writer.tool_is_extruder())
clip_length = m_config.seam_gap.get_abs_value(m_writer.tool()->id(), scale_(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, 0))); clip_length = scale_(m_config.seam_gap.get_abs_value(m_writer.tool()->id(), EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, 0)));
// get paths // get paths
ExtrusionPaths paths; ExtrusionPaths paths = loop.paths;
loop.clip_end(clip_length, &paths); ExtrusionPaths clipped;
if (clip_length > min_clip_length) {
clipped = clip_end(paths, clip_length);
clip_end(clipped, min_clip_length);
for (ExtrusionPath& ep : clipped)
ep.mm3_per_mm = 0;
append(paths, clipped);
} else {
clip_end(paths, clip_length);
}
if (paths.empty()) return ""; if (paths.empty()) return "";
// apply the small perimeter speed // apply the small perimeter speed
@ -3298,7 +3320,6 @@ std::string GCode::extrude_loop(const ExtrusionLoop &original_loop, const std::s
std::string gcode; std::string gcode;
for (ExtrusionPaths::iterator path = paths.begin(); path != paths.end(); ++path) { for (ExtrusionPaths::iterator path = paths.begin(); path != paths.end(); ++path) {
//path->simplify(SCALED_RESOLUTION); //should already be simplified //path->simplify(SCALED_RESOLUTION); //should already be simplified
//gcode += this->_extrude(*path, description, speed);
if(path->polyline.points.size()>1) if(path->polyline.points.size()>1)
gcode += extrude_path(*path, description, speed); gcode += extrude_path(*path, description, speed);
} }