Smoothen the results, fix some issues.

This commit is contained in:
PavelMikus 2023-04-13 14:03:50 +02:00 committed by Pavel Mikuš
parent 3e3ccc200e
commit f6c38fb7f9
3 changed files with 25 additions and 22 deletions

View File

@ -339,15 +339,15 @@ public:
return {distance, nearest_line_index_out, nearest_point_out}; return {distance, nearest_line_index_out, nearest_point_out};
} }
template<bool SIGNED_DISTANCE> Floating distance_from_lines(const Vec<2, typename LineType::Scalar> &point) const template<bool SIGNED_DISTANCE> Floating distance_from_lines(const Vec<2, Scalar> &point) const
{ {
auto [dist, idx, np] = distance_from_lines_extra<SIGNED_DISTANCE>(point); auto [dist, idx, np] = distance_from_lines_extra<SIGNED_DISTANCE>(point);
return dist; return dist;
} }
std::vector<size_t> all_lines_in_radius(const Vec<2, typename LineType::Scalar> &point, Floating radius) std::vector<size_t> all_lines_in_radius(const Vec<2, Scalar> &point, Floating radius)
{ {
return AABBTreeLines::all_lines_in_radius(this->lines, this->tree, point, radius * radius); return AABBTreeLines::all_lines_in_radius(this->lines, this->tree, point.template cast<Floating>(), radius * radius);
} }
template<bool sorted> std::vector<std::pair<Vec<2, Scalar>, size_t>> intersections_with_line(const LineType &line) const template<bool sorted> std::vector<std::pair<Vec<2, Scalar>, size_t>> intersections_with_line(const LineType &line) const

View File

@ -21,6 +21,7 @@
#include <iterator> #include <iterator>
#include <limits> #include <limits>
#include <numeric> #include <numeric>
#include <ostream>
#include <unordered_map> #include <unordered_map>
#include <utility> #include <utility>
#include <vector> #include <vector>
@ -268,22 +269,22 @@ public:
std::vector<ProcessedPoint> processed_points; std::vector<ProcessedPoint> processed_points;
processed_points.reserve(extended_points.size()); processed_points.reserve(extended_points.size());
for (size_t i = 0; i < extended_points.size(); i++) { for (size_t i = 0; i < extended_points.size(); i++) {
ExtendedPoint &curr = extended_points[i]; const ExtendedPoint &curr = extended_points[i];
const ExtendedPoint &next = extended_points[i + 1 < extended_points.size() ? i + 1 : i]; const ExtendedPoint &next = extended_points[i + 1 < extended_points.size() ? i + 1 : i];
// We are going to enforce slowdown over curled extrusions by increasing the point distance. The overhang speed is based on float artificial_distance_to_curled_lines = 0.0;
// 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
{ {
Vec2d middle = 0.5 * (curr.position + next.position); Vec2d middle = 0.5 * (curr.position + next.position);
auto [distance_from_curled, line_idx, auto line_indices = prev_curled_extrusions[current_object].all_lines_in_radius(Point::new_scale(middle),
p] = prev_curled_extrusions[current_object].distance_from_lines_extra<false>(Point::new_scale(middle)); scale_(10.0 * path.width));
if (distance_from_curled < scale_(2.5 * path.width)) {
float artificially_increased_distance = path.width * (1.0 - (unscaled(distance_from_curled) / (2.5 * path.width))) * for (size_t idx : line_indices) {
(prev_curled_extrusions[current_object].get_line(line_idx).curled_height / const CurledLine &line = prev_curled_extrusions[current_object].get_line(idx);
(path.height * 10.0f)); // max_curled_height_factor from SupportSpotGenerator float distance_from_curled = unscaled(line_alg::distance_to(line, Point::new_scale(middle)));
curr.distance = std::max(curr.distance, artificially_increased_distance); float dist = path.width * (1.0 - (distance_from_curled / (10.0 * path.width))) *
(1.0 - (distance_from_curled / (10.0 * path.width))) *
(line.curled_height / (path.height * 10.0f)); // max_curled_height_factor from SupportSpotGenerator
artificial_distance_to_curled_lines = std::max(artificial_distance_to_curled_lines, dist);
} }
} }
@ -303,10 +304,12 @@ public:
float extrusion_speed = std::min(interpolate_speed(speed_sections, curr.distance), float extrusion_speed = std::min(interpolate_speed(speed_sections, curr.distance),
interpolate_speed(speed_sections, next.distance)); interpolate_speed(speed_sections, next.distance));
float curled_base_speed = interpolate_speed(speed_sections, artificial_distance_to_curled_lines);
float final_speed = std::min(curled_base_speed, extrusion_speed);
float fan_speed = std::min(interpolate_speed(fan_speed_sections, curr.distance), float fan_speed = std::min(interpolate_speed(fan_speed_sections, curr.distance),
interpolate_speed(fan_speed_sections, next.distance)); interpolate_speed(fan_speed_sections, next.distance));
processed_points.push_back({scaled(curr.position), extrusion_speed, int(fan_speed)}); processed_points.push_back({scaled(curr.position), final_speed, int(fan_speed)});
} }
return processed_points; return processed_points;
} }

View File

@ -212,7 +212,7 @@ float estimate_curled_up_height(
float distance, float curvature, float layer_height, float flow_width, float prev_line_curled_height, Params params) float distance, float curvature, float layer_height, float flow_width, float prev_line_curled_height, Params params)
{ {
float curled_up_height = 0; float curled_up_height = 0;
if (fabs(distance) < 2.5 * flow_width) { if (fabs(distance) < 3.0 * flow_width) {
curled_up_height = std::max(prev_line_curled_height - layer_height * 0.75f, 0.0f); curled_up_height = std::max(prev_line_curled_height - layer_height * 0.75f, 0.0f);
} }