mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-11-28 16:11:54 -05:00
Belt printer: lay the brim as high above the belt as the part's outer wall (#16757)
On a belt the brim and the part's outer wall didn't land at the same height above the belt, so no single endstop or Y offset setting worked for both (#16705). Brim lines sat at a fixed 0.75 layer height above the belt. The outer wall where it rests on the belt sits half a layer up, because the layer is sliced at mid-height, plus half its width times tan(tilt), because it is inset half a width from the slice edge. At 45 degrees with 0.32 mm layers and a 0.4 mm wall that is 0.24 against 0.36 mm. Brim lines now sit at the clearance of the outer wall that rests on the belt in their own band's layer, with XY contour compensation included. Each line's bead is built from its spacing and clearance, so it fills its cell however small the clearance gets. Flow::with_cross_section(), used before, delivers only a quarter of the area once it falls back to a round bead. The first-layer test measured from the nozzle, so a wall resting on the belt never counted as first layer and printed at full speed with the fan on, and the raised brim would have dropped out too. It now measures from the belt under the edge of the bead. Travels use the width of the path they lead to. Brim lines are as wide as the bands are far apart, not as a bead, so they always count as resting on the belt. Speed, flow ratio and acceleration are chosen once per path, and a wall loop runs from the belt up the part, so the whole loop took whatever its seam point got. Belt paths are now cut where they cross the edge of the first-layer band or a step of the slow_down_layers ramp. Each piece is judged by the heights of all its points. Small-area flow compensation keeps using the original line lengths. Non-belt printers are unaffected. Claude-Session: https://claude.ai/code/session_01Ux9BwdWCA7N8UG7ftaNkWg Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a837652833
commit
3ac1b0078d
5 files changed
+638
-65
No files matched your search
+138
-13
@@ -3489,9 +3489,13 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
||||
// Undo what point_to_gcode() added (m_origin, minus the extruder offset) and
|
||||
// what the writer then took off (its XY offset, the plate origin).
|
||||
const Vec2d plate_offset = m_writer.get_xy_offset().cast<double>();
|
||||
// Judged like the path the travel leads to (see belt_path_height()).
|
||||
if (m_belt_travel_target != nullptr && m_belt_travel_target->role() == erBrim)
|
||||
return true;
|
||||
return this->on_first_layer(Vec3d(point_logical.x() - (m_origin.x() - plate_offset.x()) + extruder_offset.x(),
|
||||
point_logical.y() - (m_origin.y() - plate_offset.y()) + extruder_offset.y(),
|
||||
point_logical.z()));
|
||||
point_logical.z()),
|
||||
m_belt_travel_target != nullptr ? m_belt_travel_target->width : 0.);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -9229,6 +9233,89 @@ static bool overhang_fan_active(float overlap, int overhang_fan_threshold, Extru
|
||||
}
|
||||
|
||||
std::string GCode::_extrude(const ExtrusionPath &path, const std::string &path_description, double speed)
|
||||
{
|
||||
std::vector<std::vector<double>> uncut_line_lengths;
|
||||
const ExtrusionPaths pieces = this->belt_cut_at_band_edges(path, uncut_line_lengths);
|
||||
if (pieces.size() < 2)
|
||||
return this->_extrude_piece(path, path_description, speed);
|
||||
std::string gcode;
|
||||
for (size_t i = 0; i < pieces.size(); ++ i) {
|
||||
m_belt_uncut_line_lengths = &uncut_line_lengths[i];
|
||||
gcode += this->_extrude_piece(pieces[i], path_description, speed);
|
||||
}
|
||||
m_belt_uncut_line_lengths = nullptr;
|
||||
return gcode;
|
||||
}
|
||||
|
||||
// Belt printers: whether a path is on the first layer, and its step of the slow_down_layers
|
||||
// ramp, set its speed, flow and acceleration as a whole. A wall loop runs from the belt up
|
||||
// the part, so a path is cut where it crosses the edge of the first-layer band above the belt
|
||||
// or of a band of the ramp, and each piece is judged on its own. Otherwise the loop would
|
||||
// take the settings of wherever its seam is all the way round. Returns no pieces when the
|
||||
// path stays in one band, and else, for each piece, the length of the uncut line each of its
|
||||
// lines comes from, so that small-area flow compensation sees the line as it was.
|
||||
ExtrusionPaths GCode::belt_cut_at_band_edges(const ExtrusionPath &path, std::vector<std::vector<double>> &uncut_line_lengths) const
|
||||
{
|
||||
ExtrusionPaths pieces;
|
||||
// A sloped seam carries its slope along it, and a contoured path scales each line's
|
||||
// extrusion by the Z offset at the line's end, which a cut would move; both are judged
|
||||
// whole.
|
||||
if (! m_config.belt_printer.value || path.z_contoured || dynamic_cast<const ExtrusionPathSloped*>(&path) != nullptr)
|
||||
return pieces;
|
||||
// Band 0 is the first layer as on_first_layer() has it, band k > 0 the heights the ramp
|
||||
// gives step k (effective_layer_index_for_point()), the last one everything above it.
|
||||
const double first = m_config.initial_layer_print_height.value;
|
||||
const double band = this->first_layer_band_mm();
|
||||
const int last = std::max(1, m_config.slow_down_layers.value);
|
||||
auto band_of = [this, first, last](double h) {
|
||||
return h <= first + EPSILON ? 0 : std::clamp(this->belt_band_index(h), 1, last);
|
||||
};
|
||||
auto band_top = [first, band](int k) { return k == 0 ? first : (k + 1) * band; };
|
||||
const Points3 &points = path.polyline.points;
|
||||
double h_prev;
|
||||
if (points.size() < 2 || ! this->belt_path_height(path, points.front(), h_prev))
|
||||
return pieces;
|
||||
int band_prev = band_of(h_prev);
|
||||
Points3 current{ points.front() };
|
||||
std::vector<double> current_lengths;
|
||||
auto extend = [¤t, ¤t_lengths](const Point3 &p, double uncut_length) {
|
||||
if (p != current.back()) {
|
||||
current.push_back(p);
|
||||
current_lengths.push_back(uncut_length);
|
||||
}
|
||||
};
|
||||
for (size_t i = 1; i < points.size(); ++ i) {
|
||||
double h;
|
||||
this->belt_path_height(path, points[i], h);
|
||||
const int band_i = band_of(h);
|
||||
const double length = unscale<double>((points[i] - points[i - 1]).cast<double>().norm());
|
||||
// Cut at each edge the segment crosses. The belt is a plane, so the height is
|
||||
// linear along the segment.
|
||||
for (int k = band_prev; k != band_i; k += band_i > band_prev ? 1 : -1) {
|
||||
const double edge = band_top(band_i > band_prev ? k : k - 1);
|
||||
const double t = std::clamp((edge - h_prev) / (h - h_prev), 0., 1.);
|
||||
const Vec3d cut = points[i - 1].cast<double>() + t * (points[i] - points[i - 1]).cast<double>();
|
||||
const Point3 cut_point(cut.x(), cut.y(), cut.z());
|
||||
extend(cut_point, length);
|
||||
if (current.size() > 1) {
|
||||
pieces.emplace_back(Polyline3(current), path);
|
||||
uncut_line_lengths.emplace_back(std::move(current_lengths));
|
||||
}
|
||||
current = { cut_point };
|
||||
current_lengths.clear();
|
||||
}
|
||||
extend(points[i], length);
|
||||
h_prev = h;
|
||||
band_prev = band_i;
|
||||
}
|
||||
if (! pieces.empty() && current.size() > 1) {
|
||||
pieces.emplace_back(Polyline3(current), path);
|
||||
uncut_line_lengths.emplace_back(std::move(current_lengths));
|
||||
}
|
||||
return pieces;
|
||||
}
|
||||
|
||||
std::string GCode::_extrude_piece(const ExtrusionPath &path, const std::string &path_description, double speed)
|
||||
{
|
||||
std::string gcode;
|
||||
|
||||
@@ -9240,15 +9327,29 @@ std::string GCode::_extrude(const ExtrusionPath &path, const std::string &path_d
|
||||
// evaluator is inactive (non-belt printers, or belt printers without
|
||||
// a Z-axis shear) `path_on_first_layer` falls back to the legacy
|
||||
// layer-id check, so behavior is bit-identical to the pre-feature path.
|
||||
// A belt brim apron band has no Layer of its own, so it publishes its Z
|
||||
// through m_belt_brim_z instead; without that the plane would be probed at
|
||||
// Z=0 and the apron mis-classified for fan and speed.
|
||||
const Vec3d path_point_mm{
|
||||
unscale<double>(path.first_point().x()),
|
||||
unscale<double>(path.first_point().y()),
|
||||
m_layer ? m_layer->print_z : (m_belt_brim_z ? *m_belt_brim_z : 0.0)
|
||||
};
|
||||
const bool path_on_first_layer = this->on_first_layer(path_point_mm);
|
||||
bool path_on_first_layer = this->on_first_layer(path_point_mm);
|
||||
// On a belt a path is judged by how high above the belt all of it is: it is on the first
|
||||
// layer when all of it is, and takes the slow_down_layers step of its middle. A piece cut
|
||||
// at the edge of a band (see belt_cut_at_band_edges()) starts or ends on the edge, so
|
||||
// neither of its ends would do.
|
||||
int belt_layer = -1;
|
||||
if (m_config.belt_printer.value) {
|
||||
double lo = std::numeric_limits<double>::max(), hi = std::numeric_limits<double>::lowest(), h;
|
||||
for (const Point3 &p : path.polyline.points)
|
||||
if (this->belt_path_height(path, p, h)) {
|
||||
lo = std::min(lo, h);
|
||||
hi = std::max(hi, h);
|
||||
}
|
||||
if (lo <= hi) {
|
||||
path_on_first_layer = hi <= m_config.initial_layer_print_height.value + EPSILON;
|
||||
belt_layer = path_on_first_layer ? 0 : std::max(1, this->belt_band_index(0.5 * (lo + hi)));
|
||||
}
|
||||
}
|
||||
|
||||
const ExtrusionPathSloped* sloped = dynamic_cast<const ExtrusionPathSloped*>(&path);
|
||||
|
||||
@@ -9277,7 +9378,10 @@ std::string GCode::_extrude(const ExtrusionPath &path, const std::string &path_d
|
||||
z = unscale_(path.polyline.lines().begin()->a.z()) + m_nominal_z;
|
||||
}
|
||||
|
||||
// The writer's first-layer test judges the travel like the path it leads to.
|
||||
m_belt_travel_target = &path;
|
||||
gcode += this->travel_to(first_point, path.role(), "move to first " + description + " point", z);
|
||||
m_belt_travel_target = nullptr;
|
||||
|
||||
// Orca: ensure Z matches planned layer height
|
||||
if (!slope_need_z_travel && (_last_pos_undefined || m_need_change_layer_lift_z)) {
|
||||
@@ -9483,16 +9587,18 @@ std::string GCode::_extrude(const ExtrusionPath &path, const std::string &path_d
|
||||
// Use the belt-aware effective layer index when on a belt printer so
|
||||
// the speed fade tracks perpendicular distance from the plane on
|
||||
// belt printers; otherwise this falls back to the slicing layer id.
|
||||
const int _layer = this->effective_layer_index_for_point(path_point_mm);
|
||||
const int _layer = belt_layer >= 0 ? belt_layer : this->effective_layer_index_for_point(path_point_mm);
|
||||
// Belt printers: a tilted layer runs from the belt to the top of the part, so the
|
||||
// "first layers" the fan stays off for are a band along the belt. Mark where the
|
||||
// extrusion enters and leaves it, per segment, for the cooling buffer.
|
||||
const bool belt_band_tags = m_enable_cooling_markers && m_config.belt_printer.value;
|
||||
const int belt_band_layers = belt_band_tags ? m_config.close_fan_the_first_x_layers.get_at(m_writer.filament()->id()) : 0;
|
||||
auto tag_belt_band = [this, &gcode, belt_band_tags, belt_band_layers, z = path_point_mm.z()](coord_t x, coord_t y) {
|
||||
auto tag_belt_band = [this, &gcode, &path, &path_point_mm, belt_band_tags, belt_band_layers](const Point3 &p) {
|
||||
if (! belt_band_tags)
|
||||
return;
|
||||
const bool in_band = this->effective_layer_index_for_point(Vec3d(unscale<double>(x), unscale<double>(y), z)) < belt_band_layers;
|
||||
double h;
|
||||
const int layer = this->belt_path_height(path, p, h) ? this->belt_band_index(h) : this->effective_layer_index_for_point(path_point_mm);
|
||||
const bool in_band = layer < belt_band_layers;
|
||||
if (in_band != m_belt_in_band) {
|
||||
gcode += in_band ? ";_BELT_BAND_START\n" : ";_BELT_BAND_END\n";
|
||||
m_belt_in_band = in_band;
|
||||
@@ -9963,7 +10069,11 @@ std::string GCode::_extrude(const ExtrusionPath &path, const std::string &path_d
|
||||
double total_length = sloped == nullptr ? 0. : path.polyline.length() * SCALING_FACTOR;
|
||||
double saved_z = m_writer.get_position().z();
|
||||
|
||||
size_t line_idx = 0;
|
||||
for (const Line3& line : path.polyline.lines()) {
|
||||
// A line cut at a band edge above a belt is compensated as the line it was.
|
||||
const double uncut_length = m_belt_uncut_line_lengths != nullptr ? (*m_belt_uncut_line_lengths)[line_idx] : 0.;
|
||||
++ line_idx;
|
||||
std::string flow_description;
|
||||
const double line_length = line.length() * SCALING_FACTOR;
|
||||
if (line_length < EPSILON)
|
||||
@@ -9972,13 +10082,13 @@ std::string GCode::_extrude(const ExtrusionPath &path, const std::string &path_d
|
||||
auto dE = e_per_mm * line_length;
|
||||
if (_needSAFC(path)) {
|
||||
auto oldE = dE;
|
||||
dE = m_small_area_infill_flow_compensator->modify_flow(line_length, dE, path.role());
|
||||
dE = m_small_area_infill_flow_compensator->modify_flow(m_belt_uncut_line_lengths != nullptr ? uncut_length : line_length, dE, path.role());
|
||||
|
||||
if (m_config.gcode_comments && oldE > 0 && oldE != dE) {
|
||||
flow_description = description + Slic3r::format(" | Old Flow Value: %0.5f Length: %0.5f",oldE, line_length);
|
||||
}
|
||||
}
|
||||
tag_belt_band((line.a.x() + line.b.x()) / 2, (line.a.y() + line.b.y()) / 2);
|
||||
tag_belt_band(line.midpoint());
|
||||
if (path.z_contoured) {
|
||||
// ZAA: Z anti-aliased extrusion with variable Z per point
|
||||
Vec2d dest2d = this->point_to_gcode(line.b.to_point());
|
||||
@@ -10109,7 +10219,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, const std::string &path_d
|
||||
const ProcessedPoint &processed_point = new_points[i];
|
||||
const ProcessedPoint &pre_processed_point = new_points[i-1];
|
||||
Vec3d p = this->point_to_gcode_quantized(processed_point.p);
|
||||
tag_belt_band((pre_processed_point.p.x() + processed_point.p.x()) / 2, (pre_processed_point.p.y() + processed_point.p.y()) / 2);
|
||||
tag_belt_band(Point3((pre_processed_point.p + processed_point.p) / 2));
|
||||
if (m_enable_cooling_markers) {
|
||||
if (enable_overhang_bridge_fan) {
|
||||
cur_fan_enabled = overhang_fan_active(processed_point.overlap, overhang_fan_threshold, path.role());
|
||||
@@ -11496,7 +11606,22 @@ int GCode::belt_layer_past_first_layer_band(const Layer *object_layer) const
|
||||
return min_height >= this->first_layer_band_mm() - EPSILON ? 1 : 0;
|
||||
}
|
||||
|
||||
bool GCode::belt_height_above_floor(const Vec3d &point_slicing_mm, double &height_mm) const
|
||||
bool GCode::belt_path_height(const ExtrusionPath &path, const Point3 &p, double &height_mm) const
|
||||
{
|
||||
// A belt brim apron band has no Layer of its own, so it publishes its Z through
|
||||
// m_belt_brim_z; without that the belt would be probed at Z=0 and the apron
|
||||
// misjudged for fan and speed.
|
||||
const double z = m_layer ? m_layer->print_z : (m_belt_brim_z ? *m_belt_brim_z : 0.0);
|
||||
const Vec3d point(unscale<double>(p.x()), unscale<double>(p.y()), path.z_contoured ? z + unscale<double>(p.z()) : z);
|
||||
if (! this->belt_height_above_floor(point, height_mm, path.width))
|
||||
return false;
|
||||
// The brim's lines are as wide as the bands are far apart, not as the bead they lay.
|
||||
if (path.role() == erBrim)
|
||||
height_mm = 0.;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GCode::belt_height_above_floor(const Vec3d &point_slicing_mm, double &height_mm, double width) const
|
||||
{
|
||||
// The owning object, which is what carries the belt description. During
|
||||
// object-brim and coincident-apron emission m_layer still points at whichever
|
||||
@@ -11520,7 +11645,7 @@ bool GCode::belt_height_above_floor(const Vec3d &point_slicing_mm, double &heigh
|
||||
// horizontal slabs in the sliced frame, so the slab holding the material that
|
||||
// rests on the belt at this point is the one within one layer height of it.
|
||||
// A perpendicular measure would shrink the band by 1/cos(tilt).
|
||||
height_mm = point_slicing_mm.z() - floor_z;
|
||||
height_mm = point_slicing_mm.z() - floor_z - 0.5 * width * std::abs(sp.belt_floor_shear_factor);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user