mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 07:27:41 -06:00
ooze prevention update: sync with PrusaSlicer
This commit is contained in:
parent
d872c62256
commit
c3f0b5e565
2 changed files with 16 additions and 56 deletions
|
@ -256,30 +256,15 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
|||
{
|
||||
std::string gcode;
|
||||
|
||||
// move to the nearest standby point
|
||||
if (!this->standby_points.empty()) {
|
||||
// get current position in print coordinates
|
||||
Vec3d writer_pos = gcodegen.writer().get_position();
|
||||
Point pos = Point::new_scale(writer_pos(0), writer_pos(1));
|
||||
|
||||
// find standby point
|
||||
Point standby_point;
|
||||
pos.nearest_point(this->standby_points, &standby_point);
|
||||
|
||||
/* We don't call gcodegen.travel_to() because we don't need retraction (it was already
|
||||
triggered by the caller) nor reduce_crossing_wall and also because the coordinates
|
||||
of the destination point must not be transformed by origin nor current extruder offset. */
|
||||
gcode += gcodegen.writer().travel_to_xy(unscale(standby_point),
|
||||
"move to standby position");
|
||||
}
|
||||
unsigned int extruder_id = gcodegen.writer().extruder()->id();
|
||||
const ConfigOptionInts& filament_idle_temp = gcodegen.config().idle_temperature;
|
||||
|
||||
if (filament_idle_temp.get_at(extruder_id) == 0) {
|
||||
const auto& filament_idle_temp = gcodegen.config().idle_temperature;
|
||||
if (filament_idle_temp.get_at(extruder_id) > 0) {
|
||||
// There is no idle temperature defined in filament settings.
|
||||
// Use the delta value from print config.
|
||||
if (gcodegen.config().standby_temperature_delta.value != 0) {
|
||||
// we assume that heating is always slower than cooling, so no need to block
|
||||
gcode += gcodegen.writer().set_temperature(this->_get_temp(gcodegen) + gcodegen.config().standby_temperature_delta.value,
|
||||
false, gcodegen.writer().extruder()->id());
|
||||
gcode += gcodegen.writer().set_temperature
|
||||
(this->_get_temp(gcodegen) + gcodegen.config().standby_temperature_delta.value, false, extruder_id);
|
||||
gcode.pop_back();
|
||||
gcode += " ;cooldown\n"; // this is a marker for GCodeProcessor, so it can supress the commands when needed
|
||||
}
|
||||
|
@ -300,14 +285,16 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
|||
std::string();
|
||||
}
|
||||
|
||||
int
|
||||
OozePrevention::_get_temp(GCode& gcodegen)
|
||||
int OozePrevention::_get_temp(const GCode &gcodegen) const
|
||||
{
|
||||
return (gcodegen.layer() != NULL && gcodegen.layer()->id() == 0)
|
||||
// First layer temperature should be used when on the first layer (obviously) and when
|
||||
// "other layers" is set to zero (which means it should not be used).
|
||||
return (gcodegen.layer() == nullptr || gcodegen.layer()->id() == 0
|
||||
|| gcodegen.config().nozzle_temperature.get_at(gcodegen.writer().extruder()->id()) == 0)
|
||||
? gcodegen.config().nozzle_temperature_initial_layer.get_at(gcodegen.writer().extruder()->id())
|
||||
: gcodegen.config().nozzle_temperature.get_at(gcodegen.writer().extruder()->id());
|
||||
}
|
||||
|
||||
|
||||
// Orca:
|
||||
// Function to calculate the excess retraction length that should be retracted either before or after wiping
|
||||
// in order for the wipe operation to respect the filament retraction speed
|
||||
|
@ -1732,34 +1719,7 @@ namespace DoExport {
|
|||
|
||||
static void init_ooze_prevention(const Print &print, OozePrevention &ooze_prevention)
|
||||
{
|
||||
// Calculate wiping points if needed
|
||||
if (print.config().ooze_prevention.value && ! print.config().single_extruder_multi_material) {
|
||||
Points skirt_points;
|
||||
for (const ExtrusionEntity *ee : print.skirt().entities)
|
||||
for (const ExtrusionPath &path : dynamic_cast<const ExtrusionLoop*>(ee)->paths)
|
||||
append(skirt_points, path.polyline.points);
|
||||
if (! skirt_points.empty()) {
|
||||
Polygon outer_skirt = Slic3r::Geometry::convex_hull(skirt_points);
|
||||
Polygons skirts;
|
||||
for (unsigned int extruder_id : print.extruders()) {
|
||||
const Vec2d &extruder_offset = print.config().extruder_offset.get_at(extruder_id);
|
||||
Polygon s(outer_skirt);
|
||||
s.translate(Point::new_scale(-extruder_offset(0), -extruder_offset(1)));
|
||||
skirts.emplace_back(std::move(s));
|
||||
}
|
||||
ooze_prevention.enable = true;
|
||||
ooze_prevention.standby_points = offset(Slic3r::Geometry::convex_hull(skirts), float(scale_(3.))).front().equally_spaced_points(float(scale_(10.)));
|
||||
#if 0
|
||||
require "Slic3r/SVG.pm";
|
||||
Slic3r::SVG::output(
|
||||
"ooze_prevention.svg",
|
||||
red_polygons => \@skirts,
|
||||
polygons => [$outer_skirt],
|
||||
points => $gcodegen->ooze_prevention->standby_points,
|
||||
);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
ooze_prevention.enable = print.config().ooze_prevention.value && ! print.config().single_extruder_multi_material;
|
||||
}
|
||||
|
||||
// Fill in print_statistics and return formatted string containing filament statistics to be inserted into G-code comment section.
|
||||
|
@ -3776,7 +3736,8 @@ LayerResult GCode::process_layer(
|
|||
// Transition from 1st to 2nd layer. Adjust nozzle temperatures as prescribed by the nozzle dependent
|
||||
// nozzle_temperature_initial_layer vs. temperature settings.
|
||||
for (const Extruder &extruder : m_writer.extruders()) {
|
||||
if (print.config().single_extruder_multi_material.value && extruder.id() != m_writer.extruder()->id())
|
||||
if ((print.config().single_extruder_multi_material.value || m_ooze_prevention.enable) &&
|
||||
extruder.id() != m_writer.extruder()->id())
|
||||
// In single extruder multi material mode, set the temperature for the current extruder only.
|
||||
continue;
|
||||
int temperature = print.config().nozzle_temperature.get_at(extruder.id());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue