Merge branch 'main' into libvgcode

This commit is contained in:
SoftFever
2026-01-06 11:09:09 +08:00
committed by GitHub
510 changed files with 11271 additions and 4462 deletions

View File

@@ -1893,7 +1893,7 @@ void GCodeProcessor::apply_config(const PrintConfig& config)
// sanity check
if(m_preheat_steps < 1)
m_preheat_steps = 1;
m_result.backtrace_enabled = m_preheat_time > 0 && (m_is_XL_printer || (!m_single_extruder_multi_material && filament_count > 1));
m_result.backtrace_enabled = config.ooze_prevention && m_preheat_time > 0 && (m_is_XL_printer || (!m_single_extruder_multi_material && filament_count > 1));
assert(config.nozzle_volume.size() == config.nozzle_diameter.size());
m_nozzle_volume.resize(config.nozzle_volume.size());

View File

@@ -15,7 +15,6 @@
#include "../PrintConfig.hpp"
#include "SmallAreaInfillFlowCompensator.hpp"
#include "spline/spline.h"
#include <boost/log/trivial.hpp>
namespace Slic3r {
@@ -47,37 +46,43 @@ SmallAreaInfillFlowCompensator::SmallAreaInfillFlowCompensator(const Slic3r::GCo
}
} catch (...) {
std::stringstream ss;
ss << "Error parsing data point in small area infill compensation model:" << line << std::endl;
ss << "Small Area Flow Compensation: Error parsing data point in small area infill compensation model:" << line << std::endl;
throw Slic3r::InvalidArgument(ss.str());
}
}
}
for (int i = 0; i < eLengths.size(); i++) {
for (size_t i = 0; i < eLengths.size(); i++) {
if (i == 0) {
if (!nearly_equal(eLengths[i], 0.0)) {
throw Slic3r::InvalidArgument("First extrusion length for small area infill compensation model must be 0");
throw Slic3r::InvalidArgument("Small Area Flow Compensation: First extrusion length for small area infill compensation model must be 0");
}
} else {
if (nearly_equal(eLengths[i], 0.0)) {
throw Slic3r::InvalidArgument("Only the first extrusion length for small area infill compensation model can be 0");
throw Slic3r::InvalidArgument("Small Area Flow Compensation: Only the first extrusion length for small area infill compensation model can be 0");
}
if (eLengths[i] <= eLengths[i - 1]) {
throw Slic3r::InvalidArgument("Extrusion lengths for subsequent points must be increasing");
throw Slic3r::InvalidArgument("Small Area Flow Compensation: Extrusion lengths for subsequent points must be increasing");
}
}
}
if (!flowComps.empty() && !nearly_equal(flowComps.back(), 1.0)) {
throw Slic3r::InvalidArgument("Final compensation factor for small area infill flow compensation model must be 1.0");
for (size_t i = 1; i < flowComps.size(); ++i) {
if (flowComps[i] <= flowComps[i - 1]) {
throw Slic3r::InvalidArgument("Small Area Flow Compensation: Flow compensation factors must strictly increase with extrusion length");
}
}
flowModel = std::make_unique<tk::spline>();
flowModel->set_points(eLengths, flowComps);
if (!flowComps.empty() && !nearly_equal(flowComps.back(), 1.0)) {
throw Slic3r::InvalidArgument("Small Area Flow Compensation: Final compensation factor for small area infill flow compensation model must be 1.0");
}
flowModel = std::make_unique<PchipInterpolatorHelper>(eLengths, flowComps);
} catch (std::exception& e) {
BOOST_LOG_TRIVIAL(error) << "Error parsing small area infill compensation model: " << e.what();
throw;
}
}
@@ -92,7 +97,7 @@ double SmallAreaInfillFlowCompensator::flow_comp_model(const double line_length)
return 1.0;
}
return (*flowModel)(line_length);
return flowModel->interpolate(line_length);
}
double SmallAreaInfillFlowCompensator::modify_flow(const double line_length, const double dE, const ExtrusionRole role)

View File

@@ -4,12 +4,9 @@
#include "../libslic3r.h"
#include "../PrintConfig.hpp"
#include "../ExtrusionEntity.hpp"
#include "PchipInterpolatorHelper.hpp"
#include <memory>
namespace tk {
class spline;
} // namespace tk
namespace Slic3r {
class SmallAreaInfillFlowCompensator
@@ -26,8 +23,7 @@ private:
std::vector<double> eLengths;
std::vector<double> flowComps;
// TODO: Cubic Spline
std::unique_ptr<tk::spline> flowModel;
std::unique_ptr<PchipInterpolatorHelper> flowModel;
double flow_comp_model(const double line_length);

View File

@@ -1215,6 +1215,10 @@ WipeTower::ToolChangeResult WipeTower2::construct_tcr(WipeTowerWriter2& writer,
result.extrusions = std::move(writer.extrusions());
result.wipe_path = std::move(writer.wipe_path());
result.is_finish_first = is_finish;
// ORCA: Always initialize the tool_change_start_pos with a valid position
// to avoid undefined variable travel on X in Gcode.cpp function std::string WipeTowerIntegration::post_process_wipe_tower_moves
result.tool_change_start_pos = result.start_pos; // always valid fallback
return result;
}
@@ -2032,7 +2036,11 @@ WipeTower::ToolChangeResult WipeTower2::finish_layer()
// brim (first layer only)
if (first_layer) {
writer.append("; WIPE_TOWER_BRIM_START\n");
size_t loops_num = (m_wipe_tower_brim_width + spacing/2.f) / spacing;
float brim_width = m_wipe_tower_brim_width;
if (brim_width < 0.f)
brim_width = WipeTower::get_auto_brim_by_height(m_wipe_tower_height);
size_t loops_num = (brim_width + spacing / 2.f) / spacing;
for (size_t i = 0; i < loops_num; ++ i) {
poly = offset(poly, scale_(spacing)).front();

View File

@@ -58,10 +58,18 @@ public:
std::vector<std::pair<float, float>> get_z_and_depth_pairs() const;
float get_brim_width() const { return m_wipe_tower_brim_width_real; }
float get_wipe_tower_height() const { return m_wipe_tower_height; }
// ORCA: Match WipeTower API used by Print skirt/brim planning.
// Returned bounding box is in WIPE-TOWER-LOCAL coordinates (before placement on the bed).
// Include brim and y-shift to match what WT gcode actually prints.
BoundingBoxf get_bbx() const{
const float brim = m_wipe_tower_brim_width_real;
const Vec2d min(-brim, -brim + double(m_y_shift));
const Vec2d max(double(m_wipe_tower_width) + brim, double(m_wipe_tower_depth) + brim + double(m_y_shift));
return BoundingBoxf(min, max);
}
// WT2 doesn't currently compute a rib-origin compensation like WipeTower (m_rib_offset),
// so expose a zero offset for consistency purposes (to maintain API parity).
Vec2f get_rib_offset() const { return Vec2f::Zero(); }
// Switch to a next layer.
void set_layer(