mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-09-13 23:13:15 +08:00
Finish rough implementation of slowdown over curled filament
This commit is contained in:
parent
6ee674316d
commit
6e40e061f6
@ -13,6 +13,7 @@
|
|||||||
#include "../ClipperUtils.hpp"
|
#include "../ClipperUtils.hpp"
|
||||||
#include "../Flow.hpp"
|
#include "../Flow.hpp"
|
||||||
#include "../Config.hpp"
|
#include "../Config.hpp"
|
||||||
|
#include "../Line.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#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>> prev_layer_boundaries;
|
||||||
std::unordered_map<const PrintObject *, AABBTreeLines::LinesDistancer<Linef>> next_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<CurledLine>> prev_curled_extrusions;
|
||||||
std::unordered_map<const PrintObject *, AABBTreeLines::LinesDistancer<Linef>> next_curled_extrusions;
|
std::unordered_map<const PrintObject *, AABBTreeLines::LinesDistancer<CurledLine>> next_curled_extrusions;
|
||||||
const PrintObject *current_object;
|
const PrintObject *current_object;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -261,12 +262,7 @@ public:
|
|||||||
prev_layer_boundaries[object] = next_layer_boundaries[object];
|
prev_layer_boundaries[object] = next_layer_boundaries[object];
|
||||||
next_layer_boundaries[object] = AABBTreeLines::LinesDistancer<Linef>{to_unscaled_linesf(layer->lslices)};
|
next_layer_boundaries[object] = AABBTreeLines::LinesDistancer<Linef>{to_unscaled_linesf(layer->lslices)};
|
||||||
prev_curled_extrusions[object] = next_curled_extrusions[object];
|
prev_curled_extrusions[object] = next_curled_extrusions[object];
|
||||||
Linesf curled_lines;
|
next_curled_extrusions[object] = AABBTreeLines::LinesDistancer<CurledLine>{layer->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};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<ProcessedPoint> estimate_speed_from_extrusion_quality(
|
std::vector<ProcessedPoint> estimate_speed_from_extrusion_quality(
|
||||||
@ -298,11 +294,18 @@ public:
|
|||||||
estimate_points_properties<true, true, true, true>(path.polyline.points, prev_layer_boundaries[current_object], path.width);
|
estimate_points_properties<true, true, true, true>(path.polyline.points, prev_layer_boundaries[current_object], path.width);
|
||||||
|
|
||||||
for (ExtendedPoint &ep : extended_points) {
|
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
|
// We are going to enforce slowdown over curled extrusions by increasing the point distance. The overhang speed is based on
|
||||||
// the prev layer, where 0 means fully overlapping extrusions and thus no slowdown, while extrusion_width and more means full overhang,
|
// signed distance from the prev layer, where 0 means fully overlapping extrusions and thus no slowdown, while extrusion_width
|
||||||
// thus full slowdown. However, for curling, we take unsinged distance from the curled lines and artifically modifiy the distance
|
// and more means full overhang, thus full slowdown. However, for curling, we take unsinged distance from the curled lines and
|
||||||
float distance_from_curled = prev_curled_extrusions[current_object].distance_from_lines<false>(ep.position);
|
// artifically modifiy the distance
|
||||||
ep.distance = std::max(ep.distance, (path.width - distance_from_curled));
|
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;
|
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;
|
this->print_z = layer->print_z;
|
||||||
Lines obstacles;
|
Lines obstacles;
|
||||||
obstacles.reserve(layer->malformed_lines.size());
|
obstacles.reserve(layer->curled_lines.size());
|
||||||
for (const Line &l : layer->malformed_lines) { obstacles.push_back(Line{l.a + global_origin, l.b + global_origin}); }
|
for (const Line &l : layer->curled_lines) { obstacles.push_back(Line{l.a + global_origin, l.b + global_origin}); }
|
||||||
add_obstacles(obstacles);
|
add_obstacles(obstacles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef slic3r_Layer_hpp_
|
#ifndef slic3r_Layer_hpp_
|
||||||
#define slic3r_Layer_hpp_
|
#define slic3r_Layer_hpp_
|
||||||
|
|
||||||
|
#include "Line.hpp"
|
||||||
#include "libslic3r.h"
|
#include "libslic3r.h"
|
||||||
#include "BoundingBox.hpp"
|
#include "BoundingBox.hpp"
|
||||||
#include "Flow.hpp"
|
#include "Flow.hpp"
|
||||||
@ -325,7 +326,7 @@ public:
|
|||||||
coordf_t bottom_z() const { return this->print_z - this->height; }
|
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.
|
//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
|
// Collection of expolygons generated by slicing the possibly multiple meshes of the source geometry
|
||||||
// (with possibly differing extruder ID and slicing parameters) and merged.
|
// (with possibly differing extruder ID and slicing parameters) and merged.
|
||||||
|
@ -209,6 +209,18 @@ public:
|
|||||||
double a_width, b_width;
|
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
|
class Line3
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
#include "Geometry/ConvexHull.hpp"
|
#include "Geometry/ConvexHull.hpp"
|
||||||
|
|
||||||
// #define DETAILED_DEBUG_LOGS
|
// #define DETAILED_DEBUG_LOGS
|
||||||
#define DEBUG_FILES
|
// #define DEBUG_FILES
|
||||||
|
|
||||||
#ifdef DEBUG_FILES
|
#ifdef DEBUG_FILES
|
||||||
#include <boost/nowide/cstdio.hpp>
|
#include <boost/nowide/cstdio.hpp>
|
||||||
@ -234,7 +234,7 @@ float estimate_curled_up_height(
|
|||||||
|
|
||||||
if (point.curvature > 0.01){
|
if (point.curvature > 0.01){
|
||||||
float radius = std::max(1.0 / point.curvature - flow_width / 2.0, 0.001);
|
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 b = curling_t * flow_width;
|
||||||
float a = curling_section;
|
float a = curling_section;
|
||||||
float c = sqrt(std::max(0.0f,a*a - b*b));
|
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{};
|
AABBTreeLines::LinesDistancer<ExtrusionLine> prev_layer_lines{};
|
||||||
|
|
||||||
for (SupportLayer *l : layers) {
|
for (SupportLayer *l : layers) {
|
||||||
l->malformed_lines.clear();
|
l->curled_lines.clear();
|
||||||
std::vector<ExtrusionLine> current_layer_lines;
|
std::vector<ExtrusionLine> current_layer_lines;
|
||||||
|
|
||||||
for (const ExtrusionEntity *extrusion : l->support_fills.flatten().entities) {
|
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) {
|
for (const ExtrusionLine &line : current_layer_lines) {
|
||||||
if (line.curled_up_height > params.curling_tolerance_limit) {
|
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{};
|
LD prev_layer_lines{};
|
||||||
|
|
||||||
for (Layer *l : layers) {
|
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>();
|
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)};
|
AABBTreeLines::LinesDistancer<Linef> prev_layer_boundary{std::move(boundary_lines)};
|
||||||
std::vector<ExtrusionLine> current_layer_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) {
|
for (const ExtrusionLine &line : current_layer_lines) {
|
||||||
if (line.curled_up_height > params.curling_tolerance_limit) {
|
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…
x
Reference in New Issue
Block a user