Finish rough implementation of slowdown over curled filament
This commit is contained in:
parent
6ee674316d
commit
6e40e061f6
5 changed files with 40 additions and 24 deletions
|
@ -13,6 +13,7 @@
|
|||
#include "../ClipperUtils.hpp"
|
||||
#include "../Flow.hpp"
|
||||
#include "../Config.hpp"
|
||||
#include "../Line.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
@ -246,8 +247,8 @@ class ExtrusionQualityEstimator
|
|||
{
|
||||
std::unordered_map<const PrintObject *, AABBTreeLines::LinesDistancer<Linef>> prev_layer_boundaries;
|
||||
std::unordered_map<const PrintObject *, AABBTreeLines::LinesDistancer<Linef>> next_layer_boundaries;
|
||||
std::unordered_map<const PrintObject *, AABBTreeLines::LinesDistancer<Linef>> prev_curled_extrusions;
|
||||
std::unordered_map<const PrintObject *, AABBTreeLines::LinesDistancer<Linef>> next_curled_extrusions;
|
||||
std::unordered_map<const PrintObject *, AABBTreeLines::LinesDistancer<CurledLine>> prev_curled_extrusions;
|
||||
std::unordered_map<const PrintObject *, AABBTreeLines::LinesDistancer<CurledLine>> next_curled_extrusions;
|
||||
const PrintObject *current_object;
|
||||
|
||||
public:
|
||||
|
@ -261,12 +262,7 @@ public:
|
|||
prev_layer_boundaries[object] = next_layer_boundaries[object];
|
||||
next_layer_boundaries[object] = AABBTreeLines::LinesDistancer<Linef>{to_unscaled_linesf(layer->lslices)};
|
||||
prev_curled_extrusions[object] = next_curled_extrusions[object];
|
||||
Linesf curled_lines;
|
||||
curled_lines.reserve(layer->malformed_lines.size());
|
||||
for (const Line &l : layer->malformed_lines) {
|
||||
curled_lines.push_back(Linef(unscaled(l.a), unscaled(l.b)));
|
||||
}
|
||||
next_curled_extrusions[object] = AABBTreeLines::LinesDistancer<Linef>{curled_lines};
|
||||
next_curled_extrusions[object] = AABBTreeLines::LinesDistancer<CurledLine>{layer->curled_lines};
|
||||
}
|
||||
|
||||
std::vector<ProcessedPoint> estimate_speed_from_extrusion_quality(
|
||||
|
@ -296,13 +292,20 @@ public:
|
|||
|
||||
std::vector<ExtendedPoint> extended_points =
|
||||
estimate_points_properties<true, true, true, true>(path.polyline.points, prev_layer_boundaries[current_object], path.width);
|
||||
|
||||
for (ExtendedPoint& ep : extended_points) {
|
||||
// We are going to enforce slowdown by increasing the point distance. The overhang speed is based on signed distance from
|
||||
// the prev layer, where 0 means fully overlapping extrusions and thus no slowdown, while extrusion_width and more means full overhang,
|
||||
// thus full slowdown. However, for curling, we take unsinged distance from the curled lines and artifically modifiy the distance
|
||||
float distance_from_curled = prev_curled_extrusions[current_object].distance_from_lines<false>(ep.position);
|
||||
ep.distance = std::max(ep.distance, (path.width - distance_from_curled));
|
||||
|
||||
for (ExtendedPoint &ep : extended_points) {
|
||||
// We are going to enforce slowdown over curled extrusions by increasing the point distance. The overhang speed is based on
|
||||
// signed distance from the prev layer, where 0 means fully overlapping extrusions and thus no slowdown, while extrusion_width
|
||||
// and more means full overhang, thus full slowdown. However, for curling, we take unsinged distance from the curled lines and
|
||||
// artifically modifiy the distance
|
||||
auto [distance_from_curled, line_idx,
|
||||
p] = prev_curled_extrusions[current_object].distance_from_lines_extra<false>(Point::new_scale(ep.position));
|
||||
if (distance_from_curled < scale_(2.0 * path.width)) {
|
||||
float articifally_increased_distance = path.width *
|
||||
prev_curled_extrusions[current_object].get_line(line_idx).curled_height /
|
||||
(path.height * 10.0f); // max_curled_height_factor from SupportSpotGenerator
|
||||
ep.distance = std::max(ep.distance, articifally_increased_distance);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<ProcessedPoint> processed_points;
|
||||
|
|
|
@ -211,8 +211,8 @@ void JPSPathFinder::add_obstacles(const Layer *layer, const Point &global_origin
|
|||
|
||||
this->print_z = layer->print_z;
|
||||
Lines obstacles;
|
||||
obstacles.reserve(layer->malformed_lines.size());
|
||||
for (const Line &l : layer->malformed_lines) { obstacles.push_back(Line{l.a + global_origin, l.b + global_origin}); }
|
||||
obstacles.reserve(layer->curled_lines.size());
|
||||
for (const Line &l : layer->curled_lines) { obstacles.push_back(Line{l.a + global_origin, l.b + global_origin}); }
|
||||
add_obstacles(obstacles);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef slic3r_Layer_hpp_
|
||||
#define slic3r_Layer_hpp_
|
||||
|
||||
#include "Line.hpp"
|
||||
#include "libslic3r.h"
|
||||
#include "BoundingBox.hpp"
|
||||
#include "Flow.hpp"
|
||||
|
@ -325,7 +326,7 @@ public:
|
|||
coordf_t bottom_z() const { return this->print_z - this->height; }
|
||||
|
||||
//Extrusions estimated to be seriously malformed, estimated during "Estimating curled extrusions" step. These lines should be avoided during fast travels.
|
||||
Lines malformed_lines;
|
||||
CurledLines curled_lines;
|
||||
|
||||
// Collection of expolygons generated by slicing the possibly multiple meshes of the source geometry
|
||||
// (with possibly differing extruder ID and slicing parameters) and merged.
|
||||
|
|
|
@ -209,6 +209,18 @@ public:
|
|||
double a_width, b_width;
|
||||
};
|
||||
|
||||
class CurledLine : public Line
|
||||
{
|
||||
public:
|
||||
CurledLine() : curled_height(0.0f) {}
|
||||
CurledLine(const Point& a, const Point& b) : Line(a, b), curled_height(0.0f) {}
|
||||
CurledLine(const Point& a, const Point& b, float curled_height) : Line(a, b), curled_height(curled_height) {}
|
||||
|
||||
float curled_height;
|
||||
};
|
||||
|
||||
using CurledLines = std::vector<CurledLine>;
|
||||
|
||||
class Line3
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include "Geometry/ConvexHull.hpp"
|
||||
|
||||
// #define DETAILED_DEBUG_LOGS
|
||||
#define DEBUG_FILES
|
||||
// #define DEBUG_FILES
|
||||
|
||||
#ifdef DEBUG_FILES
|
||||
#include <boost/nowide/cstdio.hpp>
|
||||
|
@ -234,7 +234,7 @@ float estimate_curled_up_height(
|
|||
|
||||
if (point.curvature > 0.01){
|
||||
float radius = std::max(1.0 / point.curvature - flow_width / 2.0, 0.001);
|
||||
float curling_t = radius / 100;
|
||||
float curling_t = sqrt(radius / 100);
|
||||
float b = curling_t * flow_width;
|
||||
float a = curling_section;
|
||||
float c = sqrt(std::max(0.0f,a*a - b*b));
|
||||
|
@ -1066,7 +1066,7 @@ void estimate_supports_malformations(SupportLayerPtrs &layers, float flow_width,
|
|||
AABBTreeLines::LinesDistancer<ExtrusionLine> prev_layer_lines{};
|
||||
|
||||
for (SupportLayer *l : layers) {
|
||||
l->malformed_lines.clear();
|
||||
l->curled_lines.clear();
|
||||
std::vector<ExtrusionLine> current_layer_lines;
|
||||
|
||||
for (const ExtrusionEntity *extrusion : l->support_fills.flatten().entities) {
|
||||
|
@ -1102,7 +1102,7 @@ void estimate_supports_malformations(SupportLayerPtrs &layers, float flow_width,
|
|||
|
||||
for (const ExtrusionLine &line : current_layer_lines) {
|
||||
if (line.curled_up_height > params.curling_tolerance_limit) {
|
||||
l->malformed_lines.push_back(Line{Point::new_scale(line.a), Point::new_scale(line.b)});
|
||||
l->curled_lines.push_back(CurledLine{Point::new_scale(line.a), Point::new_scale(line.b), line.curled_up_height});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1138,7 +1138,7 @@ void estimate_malformations(LayerPtrs &layers, const Params ¶ms)
|
|||
LD prev_layer_lines{};
|
||||
|
||||
for (Layer *l : layers) {
|
||||
l->malformed_lines.clear();
|
||||
l->curled_lines.clear();
|
||||
std::vector<Linef> boundary_lines = l->lower_layer != nullptr ? to_unscaled_linesf(l->lower_layer->lslices) : std::vector<Linef>();
|
||||
AABBTreeLines::LinesDistancer<Linef> prev_layer_boundary{std::move(boundary_lines)};
|
||||
std::vector<ExtrusionLine> current_layer_lines;
|
||||
|
@ -1176,7 +1176,7 @@ void estimate_malformations(LayerPtrs &layers, const Params ¶ms)
|
|||
|
||||
for (const ExtrusionLine &line : current_layer_lines) {
|
||||
if (line.curled_up_height > params.curling_tolerance_limit) {
|
||||
l->malformed_lines.push_back(Line{Point::new_scale(line.a), Point::new_scale(line.b)});
|
||||
l->curled_lines.push_back(CurledLine{Point::new_scale(line.a), Point::new_scale(line.b), line.curled_up_height});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue