mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 08:26:03 +08:00
fix issue 9800 - Avoid Crossing Curled Overhangs Not Respecting Printer Bed Size
Fix Avoid curled overhang functionality actually not working correctly, especially on multiple objects/instances
This commit is contained in:
parent
14c3152ac9
commit
5e550709ff
@ -1032,6 +1032,10 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
|||||||
m_pressure_equalizer = make_unique<PressureEqualizer>(print.config());
|
m_pressure_equalizer = make_unique<PressureEqualizer>(print.config());
|
||||||
m_enable_extrusion_role_markers = (bool)m_pressure_equalizer;
|
m_enable_extrusion_role_markers = (bool)m_pressure_equalizer;
|
||||||
|
|
||||||
|
if (print.config().avoid_crossing_curled_overhangs){
|
||||||
|
this->m_avoid_crossing_curled_overhangs.init_bed_shape(get_bed_shape(print.config()));
|
||||||
|
}
|
||||||
|
|
||||||
// Write information on the generator.
|
// Write information on the generator.
|
||||||
file.write_format("; %s\n\n", Slic3r::header_slic3r_generated().c_str());
|
file.write_format("; %s\n\n", Slic3r::header_slic3r_generated().c_str());
|
||||||
|
|
||||||
@ -2107,8 +2111,12 @@ LayerResult GCode::process_layer(
|
|||||||
if (this->config().avoid_crossing_curled_overhangs) {
|
if (this->config().avoid_crossing_curled_overhangs) {
|
||||||
m_avoid_crossing_curled_overhangs.clear();
|
m_avoid_crossing_curled_overhangs.clear();
|
||||||
for (const ObjectLayerToPrint &layer_to_print : layers) {
|
for (const ObjectLayerToPrint &layer_to_print : layers) {
|
||||||
m_avoid_crossing_curled_overhangs.add_obstacles(layer_to_print.object_layer, Point(scaled(this->origin())));
|
if (layer_to_print.object() == nullptr)
|
||||||
m_avoid_crossing_curled_overhangs.add_obstacles(layer_to_print.support_layer, Point(scaled(this->origin())));
|
continue;
|
||||||
|
for (const auto &instance : layer_to_print.object()->instances()) {
|
||||||
|
m_avoid_crossing_curled_overhangs.add_obstacles(layer_to_print.object_layer, instance.shift);
|
||||||
|
m_avoid_crossing_curled_overhangs.add_obstacles(layer_to_print.support_layer, instance.shift);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "JumpPointSearch.hpp"
|
#include "JumpPointSearch.hpp"
|
||||||
#include "BoundingBox.hpp"
|
#include "BoundingBox.hpp"
|
||||||
|
#include "ExPolygon.hpp"
|
||||||
#include "Point.hpp"
|
#include "Point.hpp"
|
||||||
#include "libslic3r/AStar.hpp"
|
#include "libslic3r/AStar.hpp"
|
||||||
#include "libslic3r/KDTreeIndirect.hpp"
|
#include "libslic3r/KDTreeIndirect.hpp"
|
||||||
@ -181,17 +182,18 @@ public:
|
|||||||
void JPSPathFinder::clear()
|
void JPSPathFinder::clear()
|
||||||
{
|
{
|
||||||
inpassable.clear();
|
inpassable.clear();
|
||||||
obstacle_max = Pixel(std::numeric_limits<coord_t>::min(), std::numeric_limits<coord_t>::min());
|
max_search_box.max = Pixel(std::numeric_limits<coord_t>::min(), std::numeric_limits<coord_t>::min());
|
||||||
obstacle_min = Pixel(std::numeric_limits<coord_t>::max(), std::numeric_limits<coord_t>::max());
|
max_search_box.min = Pixel(std::numeric_limits<coord_t>::max(), std::numeric_limits<coord_t>::max());
|
||||||
|
add_obstacles(bed_shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JPSPathFinder::add_obstacles(const Lines &obstacles)
|
void JPSPathFinder::add_obstacles(const Lines &obstacles)
|
||||||
{
|
{
|
||||||
auto store_obstacle = [&](coord_t x, coord_t y) {
|
auto store_obstacle = [&](coord_t x, coord_t y) {
|
||||||
obstacle_max.x() = std::max(obstacle_max.x(), x);
|
max_search_box.max.x() = std::max(max_search_box.max.x(), x);
|
||||||
obstacle_max.y() = std::max(obstacle_max.y(), y);
|
max_search_box.max.y() = std::max(max_search_box.max.y(), y);
|
||||||
obstacle_min.x() = std::min(obstacle_min.x(), x);
|
max_search_box.min.x() = std::min(max_search_box.min.x(), x);
|
||||||
obstacle_min.y() = std::min(obstacle_min.y(), y);
|
max_search_box.min.y() = std::min(max_search_box.min.y(), y);
|
||||||
inpassable.insert(Pixel{x, y});
|
inpassable.insert(Pixel{x, y});
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
@ -240,9 +242,9 @@ Polyline JPSPathFinder::find_path(const Point &p0, const Point &p1)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
BoundingBox search_box({start, end, obstacle_max, obstacle_min});
|
BoundingBox search_box = max_search_box;
|
||||||
search_box.max += Pixel(1, 1);
|
search_box.max -= Pixel(1, 1);
|
||||||
search_box.min -= Pixel(1, 1);
|
search_box.min += Pixel(1, 1);
|
||||||
|
|
||||||
BoundingBox bounding_square(Points{start, end});
|
BoundingBox bounding_square(Points{start, end});
|
||||||
bounding_square.max += Pixel(5, 5);
|
bounding_square.max += Pixel(5, 5);
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define SRC_LIBSLIC3R_JUMPPOINTSEARCH_HPP_
|
#define SRC_LIBSLIC3R_JUMPPOINTSEARCH_HPP_
|
||||||
|
|
||||||
#include "BoundingBox.hpp"
|
#include "BoundingBox.hpp"
|
||||||
|
#include "Polygon.hpp"
|
||||||
#include "libslic3r/Layer.hpp"
|
#include "libslic3r/Layer.hpp"
|
||||||
#include "libslic3r/Point.hpp"
|
#include "libslic3r/Point.hpp"
|
||||||
#include "libslic3r/Polyline.hpp"
|
#include "libslic3r/Polyline.hpp"
|
||||||
@ -16,18 +17,19 @@ class JPSPathFinder
|
|||||||
using Pixel = Point;
|
using Pixel = Point;
|
||||||
std::unordered_set<Pixel, PointHash> inpassable;
|
std::unordered_set<Pixel, PointHash> inpassable;
|
||||||
coordf_t print_z;
|
coordf_t print_z;
|
||||||
Pixel obstacle_min;
|
BoundingBox max_search_box;
|
||||||
Pixel obstacle_max;
|
Lines bed_shape;
|
||||||
|
|
||||||
const coord_t resolution = scaled(1.5);
|
const coord_t resolution = scaled(1.5);
|
||||||
Pixel pixelize(const Point &p) { return p / resolution; }
|
Pixel pixelize(const Point &p) { return p / resolution; }
|
||||||
Point unpixelize(const Pixel &p) { return p * resolution; }
|
Point unpixelize(const Pixel &p) { return p * resolution; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
JPSPathFinder() { clear(); };
|
JPSPathFinder() = default;
|
||||||
void clear();
|
void init_bed_shape(const Points &bed_shape) { this->bed_shape = (to_lines(Polygon{bed_shape})); };
|
||||||
void add_obstacles(const Lines &obstacles);
|
void clear();
|
||||||
void add_obstacles(const Layer* layer, const Point& global_origin);
|
void add_obstacles(const Lines &obstacles);
|
||||||
|
void add_obstacles(const Layer *layer, const Point &global_origin);
|
||||||
Polyline find_path(const Point &start, const Point &end);
|
Polyline find_path(const Point &start, const Point &end);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1043,6 +1043,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();
|
||||||
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) {
|
||||||
@ -1114,6 +1115,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();
|
||||||
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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user