Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.9.0.70 #3861

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion BuildLinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ then
then
BUILD_ARGS="${BUILD_ARGS} -DCMAKE_BUILD_TYPE=Debug -DBBL_INTERNAL_TESTING=1"
else
BUILD_ARGS="${BUILD_ARGS} -DBBL_RELEASE_TO_PUBLIC=1 -DBBL_INTERNAL_TESTING=0"
BUILD_ARGS="${BUILD_ARGS} -DBBL_RELEASE_TO_PUBLIC=1 -DBBL_INTERNAL_TESTING=2"
fi

# cmake
Expand Down
2 changes: 1 addition & 1 deletion resources/web/homepage3/disconnect.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<div id="WarnMainArea">
<div id="WarnIcon"><img src="img/disconnect.svg" /></div>
<div id="WarnTip" class="trans TextS1" tid="t40">Network disconnect, please check and try again later.</div>
<div id="WarnBtn" class="trans Btn_Green" tid="" onClick="SwitchContent('online')">Retry</div>
<div id="WarnBtn" class="trans Btn_Green" tid="t116" onClick="SwitchContent('online')">Retry</div>
</div>

</body>
Expand Down
32 changes: 26 additions & 6 deletions src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2456,10 +2456,16 @@ void GCode::process_layers(
return this->process_layer(print, layer.second, layer_tools, &layer == &layers_to_print.back(), &print_object_instances_ordering, size_t(-1));
}
});
const auto spiral_mode = tbb::make_filter<GCode::LayerResult, GCode::LayerResult>(slic3r_tbb_filtermode::serial_in_order,
[&spiral_mode = *this->m_spiral_vase.get()](GCode::LayerResult in) -> GCode::LayerResult {
if (m_spiral_vase) {
float nozzle_diameter = EXTRUDER_CONFIG(nozzle_diameter);
float max_xy_smoothing = m_config.get_abs_value("spiral_mode_max_xy_smoothing", nozzle_diameter);
this->m_spiral_vase->set_max_xy_smoothing(max_xy_smoothing);
}
const auto spiral_mode = tbb::make_filter<GCode::LayerResult, GCode::LayerResult>(
slic3r_tbb_filtermode::serial_in_order, [&spiral_mode = *this->m_spiral_vase.get(), & layers_to_print](GCode::LayerResult in) -> GCode::LayerResult {
spiral_mode.enable(in.spiral_vase_enable);
return { spiral_mode.process_layer(std::move(in.gcode)), in.layer_id, in.spiral_vase_enable, in.cooling_buffer_flush };
bool last_layer = in.layer_id == layers_to_print.size() - 1;
return { spiral_mode.process_layer(std::move(in.gcode), last_layer), in.layer_id, in.spiral_vase_enable, in.cooling_buffer_flush};
});
const auto cooling = tbb::make_filter<GCode::LayerResult, std::string>(slic3r_tbb_filtermode::serial_in_order,
[&cooling_buffer = *this->m_cooling_buffer.get()](GCode::LayerResult in) -> std::string {
Expand Down Expand Up @@ -2504,10 +2510,16 @@ void GCode::process_layers(
return this->process_layer(print, { std::move(layer) }, tool_ordering.tools_for_layer(layer.print_z()), &layer == &layers_to_print.back(), nullptr, single_object_idx, prime_extruder);
}
});
const auto spiral_mode = tbb::make_filter<GCode::LayerResult, GCode::LayerResult>(slic3r_tbb_filtermode::serial_in_order,
[&spiral_mode = *this->m_spiral_vase.get()](GCode::LayerResult in)->GCode::LayerResult {
if (m_spiral_vase) {
float nozzle_diameter = EXTRUDER_CONFIG(nozzle_diameter);
float max_xy_smoothing = m_config.get_abs_value("spiral_mode_max_xy_smoothing", nozzle_diameter);
this->m_spiral_vase->set_max_xy_smoothing(max_xy_smoothing);
}
const auto spiral_mode = tbb::make_filter<GCode::LayerResult, GCode::LayerResult>(
slic3r_tbb_filtermode::serial_in_order, [&spiral_mode = *this->m_spiral_vase.get(), &layers_to_print](GCode::LayerResult in) -> GCode::LayerResult {
spiral_mode.enable(in.spiral_vase_enable);
return { spiral_mode.process_layer(std::move(in.gcode)), in.layer_id, in.spiral_vase_enable, in.cooling_buffer_flush };
bool last_layer = in.layer_id == layers_to_print.size() - 1;
return { spiral_mode.process_layer(std::move(in.gcode), last_layer), in.layer_id, in.spiral_vase_enable, in.cooling_buffer_flush };
});
const auto cooling = tbb::make_filter<GCode::LayerResult, std::string>(slic3r_tbb_filtermode::serial_in_order,
[&cooling_buffer = *this->m_cooling_buffer.get()](GCode::LayerResult in)->std::string {
Expand Down Expand Up @@ -4688,6 +4700,8 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
double total_length = sloped == nullptr ? 0. : path.polyline.length() * SCALING_FACTOR;
for (const Line &line : path.polyline.lines()) {
const double line_length = line.length() * SCALING_FACTOR;
// BBS: extursion cmd should E0 on cmd line
if (line_length < EPSILON) continue;
path_length += line_length;

if (sloped == nullptr) {
Expand Down Expand Up @@ -4719,6 +4733,9 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
for (size_t point_index = start_index + 1; point_index < end_index + 1; point_index++) {
const Line line = Line(path.polyline.points[point_index - 1], path.polyline.points[point_index]);
const double line_length = line.length() * SCALING_FACTOR;
// BBS: extursion cmd should E0 on cmd line
if (line_length < EPSILON)
continue;
path_length += line_length;
gcode += m_writer.extrude_to_xy(
this->point_to_gcode(line.b),
Expand All @@ -4731,6 +4748,9 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
case EMovePathType::Arc_move_ccw: {
const ArcSegment& arc = fitting_result[fitting_index].arc_data;
const double arc_length = fitting_result[fitting_index].arc_data.length * SCALING_FACTOR;
// BBS: extursion cmd should E0 on cmd line
if (arc_length < EPSILON)
continue;
const Vec2d center_offset = this->point_to_gcode(arc.center) - this->point_to_gcode(arc.start_point);
path_length += arc_length;
gcode += m_writer.extrude_arc_to_xy(
Expand Down
18 changes: 18 additions & 0 deletions src/libslic3r/GCode/GCodeProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,12 @@ void GCodeProcessor::UsedFilaments::reset()
support_volume_per_extruder.clear();
}

void GCodeProcessor::UsedFilaments::increase_support_caches(double extruded_volume)
{
support_volume_cache += extruded_volume;
role_cache += extruded_volume;
}

void GCodeProcessor::UsedFilaments::increase_model_caches(double extruded_volume)
{
color_change_cache += extruded_volume;
Expand Down Expand Up @@ -768,6 +774,18 @@ void GCodeProcessor::UsedFilaments::process_wipe_tower_cache(GCodeProcessor* pro
}
}

void GCodeProcessor::UsedFilaments::process_support_cache(GCodeProcessor* processor)
{
size_t active_extruder_id = processor->m_extruder_id;
if (support_volume_cache != 0.0f){
if (support_volume_per_extruder.find(active_extruder_id) != support_volume_per_extruder.end())
support_volume_per_extruder[active_extruder_id] += support_volume_cache;
else
support_volume_per_extruder[active_extruder_id] = support_volume_cache;
support_volume_cache = 0.0f;
}
}

void GCodeProcessor::UsedFilaments::update_flush_per_filament(size_t extrude_id, float flush_volume)
{
if (flush_per_filament.find(extrude_id) != flush_per_filament.end())
Expand Down
17 changes: 2 additions & 15 deletions src/libslic3r/GCode/GCodeProcessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,27 +511,14 @@ namespace Slic3r {

void reset();

void increase_support_caches(double extruded_volume){
support_volume_cache += extruded_volume;
role_cache += extruded_volume;
}

void increase_support_caches(double extruded_volume);
void increase_model_caches(double extruded_volume);
void increase_wipe_tower_caches(double extruded_volume);

void process_color_change_cache();
void process_model_cache(GCodeProcessor* processor);
void process_wipe_tower_cache(GCodeProcessor* processor);
void process_support_cache(GCodeProcessor* processor){
size_t active_extruder_id = processor->m_extruder_id;
if (support_volume_cache != 0.0f) {
if (support_volume_per_extruder.find(active_extruder_id) != support_volume_per_extruder.end())
support_volume_per_extruder[active_extruder_id] += support_volume_cache;
else
support_volume_per_extruder[active_extruder_id] = support_volume_cache;
support_volume_cache = 0.0f;
}
}
void process_support_cache(GCodeProcessor* processor);

void update_flush_per_filament(size_t extrude_id, float flush_length);
void process_role_cache(GCodeProcessor* processor);
Expand Down
153 changes: 137 additions & 16 deletions src/libslic3r/GCode/SpiralVase.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,77 @@
#include "SpiralVase.hpp"
#include "GCode.hpp"
#include <sstream>
#include <cmath>
#include <limits>

namespace Slic3r {

std::string SpiralVase::process_layer(const std::string &gcode)
namespace SpiralVaseHelpers {
/** == Smooth Spiral Helpers == */
/** Distance between a and b */
float distance(SpiralVase::SpiralPoint a, SpiralVase::SpiralPoint b) {
return sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2));
}

SpiralVase::SpiralPoint subtract(SpiralVase::SpiralPoint a, SpiralVase::SpiralPoint b)
{
return SpiralVase::SpiralPoint(a.x - b.x, a.y - b.y);
}

SpiralVase::SpiralPoint add(SpiralVase::SpiralPoint a, SpiralVase::SpiralPoint b) {
return SpiralVase::SpiralPoint(a.x + b.x, a.y + b.y);
}

SpiralVase::SpiralPoint scale(SpiralVase::SpiralPoint a, float factor) {
return SpiralVase::SpiralPoint(a.x * factor, a.y * factor);
}

/** dot product */
float dot(SpiralVase::SpiralPoint a, SpiralVase::SpiralPoint b) {
return a.x * b.x + a.y * b.y;
}

/** Find the point on line ab closes to point c */
SpiralVase::SpiralPoint nearest_point_on_line(SpiralVase::SpiralPoint c, SpiralVase::SpiralPoint a, SpiralVase::SpiralPoint b, float& dist)
{
SpiralVase::SpiralPoint ab = subtract(b, a);
SpiralVase::SpiralPoint ac = subtract(c, a);
float t = dot(ac, ab) / dot(ab, ab);
t = t > 1 ? 1 : t;
t = t < 0 ? 0 : t;
SpiralVase::SpiralPoint closest = SpiralVase::SpiralPoint(add(a, scale(ab, t)));
dist = distance(c, closest);
return closest;
}

/** Given a set of lines defined by points such as line[n] is the line from points[n] to points[n+1],
* find the closest point to p that falls on any of the lines */
SpiralVase::SpiralPoint nearest_point_on_lines(SpiralVase::SpiralPoint p,
std::shared_ptr<std::vector<SpiralVase::SpiralPoint>> points,
bool& found,
float& dist)
{
if (points->size() < 2) {
found = false;
return SpiralVase::SpiralPoint(0, 0);
}
float min = std::numeric_limits<float>::max();
SpiralVase::SpiralPoint closest(0, 0);
for (unsigned long i = 0; i < points->size() - 1; i++) {
float currentDist = 0;
SpiralVase::SpiralPoint current = nearest_point_on_line(p, points->at(i), points->at(i + 1), currentDist);
if (currentDist < min) {
min = currentDist;
closest = current;
found = true;
}
}
dist = min;
return closest;
}
} // namespace SpiralVase

std::string SpiralVase::process_layer(const std::string &gcode, bool last_layer)
{
/* This post-processor relies on several assumptions:
- all layers are processed through it, including those that are not supposed
Expand Down Expand Up @@ -45,19 +112,29 @@ std::string SpiralVase::process_layer(const std::string &gcode)
}
});
}

// Remove layer height from initial Z.
z -= layer_height;


std::shared_ptr<std::vector<SpiralVase::SpiralPoint>> current_layer = std::make_shared<std::vector<SpiralVase::SpiralPoint>>();
std::shared_ptr<std::vector<SpiralVase::SpiralPoint>> previous_layer = m_previous_layer;

bool smooth_spiral = m_smooth_spiral;
std::string new_gcode;
std::string transition_gcode;
float max_xy_dist_for_smoothing = m_max_xy_smoothing;
//FIXME Tapering of the transition layer only works reliably with relative extruder distances.
// For absolute extruder distances it will be switched off.
// Tapering the absolute extruder distances requires to process every extrusion value after the first transition
// layer.
bool transition = m_transition_layer && m_config.use_relative_e_distances.value;
float layer_height_factor = layer_height / total_layer_length;
bool transition_in = m_transition_layer && m_config.use_relative_e_distances.value;
bool transition_out = last_layer && m_config.use_relative_e_distances.value;
float len = 0.f;
m_reader.parse_buffer(gcode, [&new_gcode, &z, total_layer_length, layer_height_factor, transition, &len]
//set initial point
SpiralVase::SpiralPoint last_point = previous_layer != NULL && previous_layer->size() > 0 ? previous_layer->at(previous_layer->size()-1): SpiralVase::SpiralPoint(0,0);

m_reader.parse_buffer(gcode, [&new_gcode, &z, total_layer_length, layer_height, transition_in, &len, &current_layer, &previous_layer, &transition_gcode, transition_out,
smooth_spiral, &max_xy_dist_for_smoothing, &last_point]
(GCodeReader &reader, GCodeReader::GCodeLine line) {
if (line.cmd_is("G1")) {
if (line.has_z()) {
Expand All @@ -69,29 +146,73 @@ std::string SpiralVase::process_layer(const std::string &gcode)
} else {
float dist_XY = line.dist_XY(reader);
if (dist_XY > 0) {
// horizontal move
if (line.extruding(reader)) {
if (line.extruding(reader)) { // Exclude wipe and retract
len += dist_XY;
line.set(reader, Z, z + len * layer_height_factor);
if (transition && line.has(E))
// Transition layer, modulate the amount of extrusion from zero to the final value.
line.set(reader, E, line.value(E) * len / total_layer_length);
float factor = len / total_layer_length;
if (transition_in)
// Transition layer, interpolate the amount of extrusion from zero to the final value.
line.set(reader, E, line.e() * factor, 5 /*decimal_digits*/);
else if (transition_out) {
// We want the last layer to ramp down extrusion, but without changing z height!
// So clone the line before we mess with its Z and duplicate it into a new layer that ramps down E
// We add this new layer at the very end
GCodeReader::GCodeLine transitionLine(line);
transitionLine.set(reader, E, line.e() * (1 - factor), 5 /*decimal_digits*/);
transition_gcode += transitionLine.raw() + '\n';
}
// This line is the core of Spiral Vase mode, ramp up the Z smoothly
line.set(reader, Z, z + factor * layer_height);
if (smooth_spiral) {
// Now we also need to try to interpolate X and Y
SpiralVase::SpiralPoint p(line.x(), line.y()); // Get current x/y coordinates
current_layer->push_back(p); // Store that point for later use on the next layer
if (previous_layer != NULL) {
bool found = false;
float dist = 0;
SpiralVase::SpiralPoint nearestp = SpiralVaseHelpers::nearest_point_on_lines(p, previous_layer, found, dist);
if (found && dist < max_xy_dist_for_smoothing) {
// Interpolate between the point on this layer and the point on the previous layer
SpiralVase::SpiralPoint target = SpiralVaseHelpers::add(SpiralVaseHelpers::scale(nearestp, 1 - factor), SpiralVaseHelpers::scale(p, factor));

// BBS: remove too short movement
// We need to figure out the distance of this new line!
float modified_dist_XY = SpiralVaseHelpers::distance(last_point, target);
if (modified_dist_XY < 0.001)
line.clear();
else {
line.set(reader, X, target.x);
line.set(reader, Y, target.y);
// Scale the extrusion amount according to change in length
line.set(reader, E, line.e() * modified_dist_XY / dist_XY, 5 /*decimal_digits*/);
last_point = target;
}
} else {
last_point = p;
}
}
}
new_gcode += line.raw() + '\n';
}
return;

/* Skip travel moves: the move to first perimeter point will
cause a visible seam when loops are not aligned in XY; by skipping
it we blend the first loop move in the XY plane (although the smoothness
of such blend depend on how long the first segment is; maybe we should
enforce some minimum length?). */
enforce some minimum length?).
When smooth_spiral is enabled, we're gonna end up exactly where the next layer should
start anyway, so we don't need the travel move */
}
}
}
new_gcode += line.raw() + '\n';
if(transition_out) {
transition_gcode += line.raw() + '\n';
}
});

return new_gcode;

m_previous_layer = current_layer;

return new_gcode + transition_gcode;
}

}
24 changes: 20 additions & 4 deletions src/libslic3r/GCode/SpiralVase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,48 @@

namespace Slic3r {

class SpiralVase {
class SpiralVase
{
public:
class SpiralPoint
{
public:
SpiralPoint(float paramx, float paramy) : x(paramx), y(paramy) {}

public:
float x, y;
};
SpiralVase(const PrintConfig &config) : m_config(config)
{
//BBS
//m_reader.z() = (float)m_config.z_offset;
m_reader.z() = 0.0f;
m_reader.apply_config(m_config);
m_previous_layer = NULL;
m_smooth_spiral = config.spiral_mode_smooth;
};

void enable(bool en) {
m_transition_layer = en && ! m_enabled;
m_enabled = en;
}

std::string process_layer(const std::string &gcode);

std::string process_layer(const std::string &gcode, bool last_layer);
void set_max_xy_smoothing(float max) {
m_max_xy_smoothing = max;
}
private:
const PrintConfig &m_config;
GCodeReader m_reader;
float m_max_xy_smoothing = 0.f;

bool m_enabled = false;
// First spiral vase layer. Layer height has to be ramped up from zero to the target layer height.
bool m_transition_layer = false;
// Whether to interpolate XY coordinates with the previous layer. Results in no seam at layer changes
bool m_smooth_spiral = false;
std::shared_ptr<std::vector<SpiralPoint>> m_previous_layer;
};

}

#endif // slic3r_SpiralVase_hpp_
Loading